Home » JAVA Programming » Arrays » Question
  1. What is the output of this program?

    public class arr_output
    {
    public static void main(String args[])
    {
    int arr_var[][] = {{ 1, 2, 3, 4}, { 4 , 5, 6, 7}, { 7, 8, 9, 10}};
    int sum = 0;
    for (int i = 0; i < 3; ++i)
    {
    for (int j = 0; j < 3 ; ++j)
    {
    sum = sum + arr_var[i][j];
    }
    }
    System.out.print(sum / 2);
    }
    }
    1. 10
    2. 15
    3. 20
    4. 22
    5. 12
Correct Option: D

None
Output: 22



Your comments will be displayed only after manual approval.