πŸ“Š JAVA
Q. What will be the output of the following Java code?
class multidimention_array
{
public static void main(String args[])
{
int arr[][] = new int[3][];
arr[0] = new int[1];
arr[1] = new int[2];
arr[2] = new int[3];
int sum = 0;
for (int i = 0; i < 3; ++i)
for (int j = 0; j < i + 1; ++j)
arr[i][j] = j + 1;
for (int i = 0; i < 3; ++i)
for (int j = 0; j < i + 1; ++j)
sum + = arr[i][j];
System.out.print(sum);
}
}
  • (A) 11
  • (B) 10
  • (C) 13
  • (D) 14
πŸ’¬ Discuss
βœ… Correct Answer: (B) 10

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
78
Total Visits
πŸ“½οΈ
11 mo ago
Published
πŸŽ–οΈ
Vikash Gupta
Publisher
πŸ“ˆ
86%
Success Rate