

MCQOPTIONS
Saved Bookmarks
1. |
What is the output of this program?
public class multidimention_arr { public static void main(String args[]) { int array[][] = new int[5][5]; array[0] = new int[1]; array[1] = new int[2]; array[2] = new int[3]; int sum = 0; for (int i = 0; i < 5; ++i) { for (int j = 0; j < i + 1; ++j) { array[i][j] = j + 1; } } for (int i = 0; i < 5; ++i) { for (int j = 0; j < i + 1; ++j) { sum = sum + array[i][j]; } } System.out.print(sum); } } |
A. | 25 |
B. | 10 |
C. | 35 |
D. | 20 |
E. | 30 |
Answer» D. 20 | |