A

Admin • 833K Points
Coach

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);
  • (A) Marks=0
  • (B) Marks=10
  • (C) Marks=20
  • (D) Compiler error
  • Correct Answer - Option(C)
  • Views: 38
  • Filed under category Java
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.