giovedì 28 marzo 2013

Q65

Given the code fragment:
public class X  {
       public static void main(String[] args) {
             String[] table = { "aa", "bb", "cc" };
             int ii = 0;
             for (String ss : table) {
                    while (ii < table.length) {
                          System.out.println(ii);
                          ii++;
                          break;
                    }
             }
       }
}

How many times is 2 printed?
A.
zero
B.
once
C.
twice
D.
thrice
E.
it is not printed because compilation fails
Risposta : B. viene stampato una volta.

 

Nessun commento:

Posta un commento