1. public class Example7 {
2. public static void main(String args[]) {
3 . Example7 e7 = new Example7();
4. int b = ? ;
5. e7.Movie(b);
6. }
7. public void Movie(int q) {
8. switch (q) {
9. case 1:
10. System.out.print("me ");
11. case 2:
12 .System.out.print("myself ");
13 .break;
14. case 3:
15. System.out.print("Irene ");
16. default:
17. System.out.print("Movie");
18. }}}
Which input-output option is correct :
(1).a = 4, Output = " Movie"
(2)a=0, Output="me myself"
(3)a=3,Output="Irene Movie"
(4)a= 1, Output = " me"
(1) & (3)
Since break is in between case1 & case 2 , the case switch will continue until it meets to break or end of the program. Input 0 & 1 produce -'Movie' & 'me myself' respectively.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.