Home / Questions / Rewrite the following using ternary operator: if (x%2 == 0) System.out.print("EVEN"); else System.out.print("ODD");
Explanatory Question

Rewrite the following using ternary operator:

if (x%2 == 0)
System.out.print("EVEN");
else
System.out.print("ODD");

👁 70 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation


System.out.print(x%2 == 0 ? "EVEN" : "ODD");