Given the code fragment: (Exhibit) How many times is 2 printed?

By | January 7, 2023

Given the code fragment:

How many times is 2 printed?

Correct Answer: B
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.