Oracle
1Z0-803 · Question #35
Given the code fragment: How many times is 2 printed?
The correct answer is B. once. The outer loop will run three times, one time each for the elements in table. The break statement breaks the inner loop immediately each time. 2 will be printed once only. Note: If the line int ii = 0; is missing the program would not compile.
Using Loop Constructs
Question
Given the code fragment:
How many times is 2 printed?
Exhibit
Options
- Azero
- Bonce
- Ctwice
- Dthrice
- Eit is not printed because compilation fails
How the community answered
(50 responses)- A2% (1)
- B82% (41)
- C2% (1)
- D6% (3)
- E8% (4)
Explanation
The outer loop will run three times, one time each for the elements in table. The break statement breaks the inner loop immediately each time. 2 will be printed once only. Note: If the line int ii = 0; is missing the program would not compile.
Topics
#loops#conditional statements#output prediction#iteration count
Community Discussion
No community discussion yet for this question.
