Menu
Question Index
...

What will be the output of the following program?

class ArrayOutput
{
    public static void main(String s[])
    {
        int a[] = new int[50];
    
        int i = 27 % 11;
        int j = 2 * 2;
        int k = i - j;
    
        a[i] = j;
        a[j] = i;
        a[k] = k;
    
        int sum = 0;
    
        for(int l = 0; l < a.length; l++)
        {
            sum += a[k];
        }
        System.out.println("Sum = " + sum);
    }
}


Sum = 10
Sum = 30
Sum = 50
Compilation error
Throws ArrayIndexOutOfBoundsException

Doubts

Problems

Topic: Learn Arrays And Loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App