answer this pleasee:D
Attachments:
Answers
Answered by
2
Question:-
- Find the output of the following code.
Solution:-
Given code,
switch(x)
{
case 1: System.out.println("Monday");
case 2: System.out.println("Tuesday.");
break;
case 3: System.out.println("Wednesday.");
default: System.out.println("No match");
break;
}
When x=1;
case 1 will execute.
As no break keyword is given so case 2 will also execute.
Output:-
Monday
Tuesday
When x=4, none of the case value is matching.
So, Output:- No match.
Output:-
No match.
Answered by
3
Answer:
Output1:
Monday
Tuesday
//beacuse of no break statement after case 1 fall through will occur
Output 4:
no match
Similar questions