A student executes the following program segment and gets an error. Identify the statement which has an error, correct the same to get the output as WIN.
Advertisements
Question
A student executes the following program segment and gets an error. Identify the statement which has an error, correct the same to get the output as WIN.
boolean x=true;
switch(x)
{ case 1:System.out.println("WIN");break;
case 2;System.out.println("LOOSE");
}One Line Answer
Advertisements
Solution
Statement with error - boolean x=true ; To get the required output - int x=1;
shaalaa.com
Introduction of Conditional Statements in Java
Is there an error in this question or solution?
