what is the output of the following code below ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what is the output of the following code below ?

int a = 11; int b = 12; int c = 40; switch (a) { case 40 : System.out.println(b); break; default : System.out.println(c); } plz help me answer the question above...thnks

22nd Jun 2019, 2:19 PM
Boy Arya
Boy Arya - avatar
2 Answers
+ 11
Hello !! Here the 40 would be printed as you are checking variable 'a' for a single case of 40. The value of 'a' is 11 so case 40 is false and the last default block is executed and value of variable 'c' is printed i.e. 40. Hope This Helps !!!
22nd Jun 2019, 2:26 PM
Nova
Nova - avatar
0
40
22nd Jun 2019, 2:21 PM
Maxim Balakirev
Maxim Balakirev - avatar