What is x equal to after the following code is executed?
int x = 0;
x++;
1
What is x equal to after the following code is executed?
int x = 1;
x--;
0
If A is true, B is true and C is true, is the following compound statement true or false?
(A && B) && (B || C)
True
Consider the following code:
int a = 0;
int b = 0;
while (a < 5 && b < 3)
{
System.out.println(a + " " + b);
a++;
b++;
}
What is output?
00
11
22
Consider the following code:
int n = 14;
while (!(n % 3 == 0 && n % 5 == 0))
{
System.out.println(n);
n += 2;
}
28
What is one potential problem with the following loop?
System.out.print("Enter integers. Enter -1 to exit.");
System.out.println(" Count of integers entered will be returned.");
int n = 0;
int c = 0;
, while (n != -1)
{
n = scan.nextInt();
c++;
}
System.out.println(c);
The loop counts when the user enters -1 into the keyboard, so the count will be one too
many.
What is one potential problem with the following loop?
int n = 5;
while (n != -1)
{
System.out.println(n);
}
Since n does not change the loop will not stop.
Consider the following code:
int n = 4;
while (n <= 15)
{
n += 2;
System.out.print(n + " ");
}
6 8 10 12 14 16
Consider the following code:
int n = 80;
while (n > 40)
{
System.out.print(n % 10 + " ");
n -= 5;
}
05050505
A while loop is an example of ______
iteration
Consider the following code:
int a = scan.nextInt();
int b = scan.nextInt();
while (a < b)
{
a += b % a;
System.out.println(a + " " + b);
}