Q15
Given:
public class DoCompare1 {
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
Zero
B.
Once
Once
C.
Twice
Twice
D.
3 times
3 times
E.
Compilation fails.
Compilation fails.
Risultato D : 3 volte
infatti per ogni elemento dell'array di Stinghe table vengono stampati i numero 0, 1 e 2. uscita:
aa, 0
aa, 1
aa, 2
bb, 0
bb, 1
bb, 2
cc, 0
cc, 1
cc, 2
In un' altra versione questa domanda potrebbe avere come risposta la non compilazione a causa di alcune parentesi mancanti :

Nessun commento:
Posta un commento