🎴 Flashcard Mode
Java Operators (GATE - CS)
Card1 / 15
Mastered0
Review0
QuestionClick to flip
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");
}
}
}
AnswerClick to flip back
A
Compilation Error
💡 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.