MCQ Practice Single Best Answer Topic: ICSE Computer Application - Class X - 2023 PYQ

Q Consider the following program segment and select the output of the same when n = 10 :

switch(n)
{
    case 10 : System.out.println(n*2); 
    case 4 : System.out.println(n*4); break; 
    default : System.out.println(n);
}

Question ID
#23958
Subchapter
ICSE Computer Application - Class X - 2023 PYQ
Action
Choose one option below

Choose Your Answer

Click an option to check whether your answer is correct.

  • A 20
    40
  • B 10
    4
  • C 20, 40
  • D 10
    10
Correct Answer: A

Explanation

20
40

Reason — Since n = 10, case 10 will be executed. It prints 20 (10 * 2) on the screen. Since break statement is missing, the execution falls through to the next case. Case 4 prints 40 (10 * 4) on the screen. Now the control finds the break statement and the control comes out of the switch statement.

Share This Question

Share this MCQ with your friends or study group.