Computer Applications
Explain with an example the if-else-if construct.
Java Conditional Stmts
ICSE 2007
138 Likes
Answer
if - else - if ladder construct is used to test multiple conditions and then take a decision. It provides multiple branching of control. Below is an example of if - else - if:
if (marks < 35)
System.out.println("Fail");
else if (marks < 60)
System.out.println("C grade");
else if (marks < 80)
System.out.println("B grade");
else if (marks < 95)
System.out.println("A grade");
else
System.out.println("A+ grade");
Answered By
88 Likes