Convert the following switch case into if else if :

ICSE Class 10 Computer Applications PYQ · 2025 Improvement · Section A

2(iii)1 Mark · 2025 · Section A · 2025 Improvement

Convert the following switch case into if else if:

switch(x) 
{ 
case 'T' : 
case  't'  : System.out.print("Teacher");  break; 
default  :  System.out.print("Student");   
}
Show SolutionHide Solution↓
if (x == 'T' || x == 't') {
    System.out.print("Teacher");
} else {
    System.out.print("Student");
}
← Previous questionNext question →

Share on WhatsApp

Browse the free Computer Applications sample bank