1.

Convert the following if else if construct into switch case.if( var==1)System.out.println("good");else if(var==2)System.out.println("better");else if(var==3)System.out.println("best");elseSystem.out.println("invalid");

Answer»

switch(var)

{

case 1: System.out.println(“good”);

break;

case 2: System.out.println(“better”);

break;

case 3: System.out.println(“best”);

break;

default: System.out.println(“invalid”);

}



Discussion

No Comment Found

Related InterviewSolutions