Q. What is the output of the Java code snippet with a Ternary operator?
Code:
void show()
{
int num = true ? getNumber() : 20;
System.out.print("TOMATO=" + num);
}
void getNumber()
{
System.out.print(30);
}
β
Correct Answer: (D)
Compiler error