class NestedFor { public static void main(String s[]) { int sum = 23;
for(int i = 2; i <= 5; i++ ) { for(int j = 7; j <= 9; j++ ) { sum += ( i * j); } }
System.out.println("sum = " + sum); } }
sum = 336
sum = 359
Compilation errors
sum = 45
Correct Answer : B
In this program, sum is initialised to 23 and i is initialized to 2. i is incremented after every completion of the inner loop of j. j starts from 7 and goes up to 9. At the end of the program, sum gets the value 359.
The answer is B.