Predict the output: p = 1 int a = 1, b = 2, c = 3; switch(p) { case 1: a++; case 2: ++b; break; case 3: c--; } System.out.println(a + "," + b + "," + c);
Advertisements
Question
Predict the output:
p = 1
int a = 1, b = 2, c = 3;
switch(p)
{
case 1: a++;
case 2: ++b;
break;
case 3: c--;
}
System.out.println(a + "," + b + "," + c);
One Line Answer
Advertisements
Solution
2, 3, 3
shaalaa.com
Is there an error in this question or solution?
Chapter 1.08: Conditional Statements in Java - EXERCISES [Page 99]
