Multiple choice

What is the output of the given java code?

public class HelloWorld
{
public static void main(String []args)
{
boolean i=1;
switch(Math.round(Math.hypot(114,123))) // Line 1
{
default : System.out.println("Default Case");
case 128<<6<<3 : System.out.println("Case 1");
case 9072/54 : System.out.println("Case 2");
case 128<<4<<2 : System.out.println("Case 3");
}
}
}

  1. Default Case Case 1 Case 2 Case 3

  2. Case 1Case 2Case 3

  3. Case 2Case 3

  4. Case 3

  5. Compilation Error

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

There is an error in the program because Math.round() function returns a “long” type of value and we cannot pass a “long” type of value in a switch() case. So the compiler will raise an error that “required:int, Found: long”. So this is the correct choice.