What will the following program print?.
public class Main{ public static void main (String args []){ int k = 9, s = 5; switch (k){ default : if ( k == 10) { s = s*2; } else{/*from w w w . j a v a 2s . c o m*/ s = s+4; break; } case 7 : s = s+3; } System.out.println (s); } }
Select 1 option
Correct Option is : B
Since 9 does not match any of the case labels, it is accepted by default block.
In this block, the else part is executed, which sets s to the value of s+4.
Since there is a break in the else block, case 7: is not executed.