Question
class Test
{
public static void main(String [] args)
{
int x=20;
String sup = (x < 15) ? "small" : (x < 22)? "tiny" : "huge";
System.out.println(sup);
}
}
What will be the output of the program?
class Test
{
public static void main(String [] args)
{
int x=20;
String sup = (x < 15) ? "small" : (x < 22)? "tiny" : "huge";
System.out.println(sup);
}
}
Answer: Option B
Was this answer helpful ?
This is an example of a nested ternary operator. The second evaluation (x < 22) is true,
so the "tiny" value is assigned to sup.
Was this answer helpful ?
More Questions on This Topic :
Question 2.
Which of these statements are incorrect?
....
Submit Solution