Multiple choice

How many times is 0 printed as part of output?

public class ScopeTest
{
int z;
public static void main(String[] args)
{
String[] table = {aa, bb, cc};
for (String ss: table)
{
int ii = 0;
while (ii < table.length)
{
System.out.println(ss + , + ii);
ii++;
}
}
}
}

  1. Zero

  2. Once

  3. Twice

  4. Thrice

  5. Compilation error

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

This is the correct choice. The for statement, for (String ss: table) is executed one time for each of the three elements in table.