Q. What is the output of the Java code snippet with a Ternary operator?
Code:String name = "cat";
int marks = name == "Cat"?10:20;
System.out.println("Marks=" + marks);
β
Correct Answer: (C)
Marks=20
String name = "cat";
int marks = name == "Cat"?10:20;
System.out.println("Marks=" + marks);
You must be Logged in to update hint/solution