A

Admin • 832.27K Points
Coach

Q. What is the output of the Java code snippet with a Ternary operator?

Code:
String name1 = "pen";
String name2 = "pen";
int marks = name2.equals(name1)?50:80;
System.out.println("Marks=" + marks);
  • (A) Marks=0
  • (B) Marks=50
  • (C) Marks=80
  • (D) Compiler error
  • Correct Answer - Option(B)
  • Views: 28
  • 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.