lunedì 14 aprile 2014

Java 7 OCA 1z0-803: How many times is 2 printed as a part of the output?

Given the following:
public class DoCompare {
 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++;
   }
  }
 }
}
How many times is 2 printed as a part of the output?
A - Zero.
B - Once.
C - Twice.
D - Thrice.
E - Compilation fails.
Answer: D
More questions about Java 7 OCA 1z0-803?