मराठी

Consider the following program segment and select the output of the same when n = 10: - Computer Applications

Advertisements
Advertisements

प्रश्न

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

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

पर्याय

  • 20
    40

  • 10
    4

  • 20, 40

  • 10
    10

MCQ

उत्तर

20
40

Explanation:

The value of n = 10 matches the 1st case, so n*2 = 20 is printed. Since there is no break, the control also goes to the next case and printsn*4 = 40 in a new line. Then, a break is encountered.

shaalaa.com
Introduction of Conditional Statements in Java
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2022-2023 (March) Official
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×