Menu
Question Index
...

What will be the output of the program?

class Output
{
    final static short i = 2;
    public static int j = 0;
    
    public static void main(String [] args)
    {
        for (int k = 0; k < 3; k++)
        {
            switch (k)
            {
                case i: System.out.print(" 0 ");
                case i-1: System.out.print(" 1 ");
                case i-2: System.out.print(" 2 ");
            }
        }
    }
}


2 1 0 1 0 0
0 1 2 1 2 2
2 1 2 0 1 2
0 1 2
Compilation Error

Doubts

Problems

Topic: final Keyword In Java Static Keyword In Java

Read this topic Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App