Else and Ternary Operator
What is the syntax for a basic if-else statement in Java? - 🧠 ANSWER
✔✔public class IfElseExample { public static void main(String[] args) { int
score = 72; if (score >= 50) { System.out.println("Pass"); } else {
System.out.println("Fail"); } }}
What is the purpose of the ternary operator in Java? - 🧠 ANSWER ✔✔It is a
shorthand for if-else statements, allowing for conditional assignments.
What is the structure of a ternary operation? - 🧠 ANSWER ✔✔Identifier
(result) = (condition) ? Value if true : Value if false;