Microsoft
MB6-890 · Question #51
What is the return value of the following method, for an initial value of x = 5? static int sampleSwitch(int x) { ; switch (x) { case (1): x = 5; case (5): x = x + 5; case (10): x = x + 10; break…
The correct answer is C. 20. See the full explanation below for the reasoning.
Question
What is the return value of the following method, for an initial value of x = 5? static int sampleSwitch(int x) { ; switch (x) { case (1):
x = 5; case (5):
x = x + 5; case (10):
x = x + 10; break; case (20):
x = x + 20; break; default:
x = 5; } info(strfmt("Return value is %1", x)); return x; }
Options
- A5
- B10
- C20
- D25
How the community answered
(58 responses)- A10% (6)
- B2% (1)
- C83% (48)
- D5% (3)
Community Discussion
No community discussion yet for this question.