471
default: outData.println("Whoops!");
}
12.If a whileloop whose condition is delta <= alphais converted to a doloop, the
loop condition of the doloop is delta > alpha. (True or False?)
13.A dostatement always ends in a semicolon. (True or False?)
14.What is printed by the following code fragment? (All variables are of type int.)
n = 0 ;
i = 1 ;
do
{
outData.print(i);
i++;
} while(i <= n);
15.What is printed by the following code fragment? (All variables are of type int.)
n = 0 ;
for(i = 1 ; i <= n; i++)
outData.print(i);
16.What is printed by the following code fragment? (All variables are of type int.)
for(i = 4 ; i >= 1 ; i--)
{
for(j = i; j >= 1 ; j--)
outData.print(j + " ");
outData.println(i);
}
17.What is printed by the following code fragment? (All variables are of type int.)
for(row = 1 ; row <= 10 ; row++)
{
for(col = 1 ; col <= 10 – row; col++)
outData.print("*");
for(col = 1 ; col <= 2 * row – 1 ; col++)
outData.print(" ");
for(col = 1 ; col <= 10 – row; col++)
outData.print("*");
outData.println();
}