1
In the following code, what value should go in the blank so that there will be exactly six lines of output?
for (int x = 0; x < _____; x = x + 2)
System.out.println ("-");
A. 5
B. 6
C. 10
D. 11
E. 13
Correct Answer: D
Explanation:
2
What will be the largest value printed by the following code?
for (int x = 5; x > 0; x--)
for (int y = 0; y < 8; y++)
System.out.println (x*y);
A. 5
B. 8
C. 35
D. 40
E. 64
Correct Answer: C
Explanation:
3
Assume num and max are integer variables. Consider the code
While (num < max)
num++;
Which values of num and max will cause the body of the loop to be executed exactly once?
A. num = 1, max = 1;
B. num = 1, max = 2;
C. num = 2, max = 2;
D. num = 2, max = 1;
E. num = 1, max = 3;
Correct Answer: B
Explanation:
4
Which for loop is equivalent to this while loop?
int y = 5;
while (y >= 0)
{
System.out.println (y);
y--;
}
A. for (int y = 0; y < 5; y++)
System.out.println (y);
B. for (int y = 5; y > 0; y--)
System.out.println (y);
C. for (int y = 5; y >= 0; y--)
System.out.println (y);
D. for (int y = 0; y > 5; y++)
System.out.println (y);
E. for (int y = 0; y > 5; y--)
System.out.println (y);
Correct Answer: C
Explanation:
5
Which expression tests to make sure the grade is between 0 and 100 inclusive?
A. (grade <= 100) || (grade <= 0)
B. (grade <= 100) || (grade >= 0)
C. (grade < 101) || (grade > -1)
D. (grade <= 100) && (grade >= 0)
E. (grade >= 100) && (grade <= 0)
Correct Answer: D
Explanation:
1
In the following code, what value should go in the blank so that there will be exactly six lines of output?
for (int x = 0; x < _____; x = x + 2)
System.out.println ("-");
A. 5
B. 6
C. 10
D. 11
E. 13
Correct Answer: D
Explanation:
2
What will be the largest value printed by the following code?
for (int x = 5; x > 0; x--)
for (int y = 0; y < 8; y++)
System.out.println (x*y);
A. 5
B. 8
C. 35
D. 40
E. 64
Correct Answer: C
Explanation:
3
Assume num and max are integer variables. Consider the code
While (num < max)
num++;
Which values of num and max will cause the body of the loop to be executed exactly once?
A. num = 1, max = 1;
B. num = 1, max = 2;
C. num = 2, max = 2;
D. num = 2, max = 1;
E. num = 1, max = 3;
Correct Answer: B
Explanation:
4
Which for loop is equivalent to this while loop?
int y = 5;
while (y >= 0)
{
System.out.println (y);
y--;
}
A. for (int y = 0; y < 5; y++)
System.out.println (y);
B. for (int y = 5; y > 0; y--)
System.out.println (y);
C. for (int y = 5; y >= 0; y--)
System.out.println (y);
D. for (int y = 0; y > 5; y++)
System.out.println (y);
E. for (int y = 0; y > 5; y--)
System.out.println (y);
Correct Answer: C
Explanation:
5
Which expression tests to make sure the grade is between 0 and 100 inclusive?
A. (grade <= 100) || (grade <= 0)
B. (grade <= 100) || (grade >= 0)
C. (grade < 101) || (grade > -1)
D. (grade <= 100) && (grade >= 0)
E. (grade >= 100) && (grade <= 0)
Correct Answer: D
Explanation:
In the following code, what value should go in the blank so that there will be exactly six lines of output?
for (int x = 0; x < _____; x = x + 2)
System.out.println ("-");
A. 5
B. 6
C. 10
D. 11
E. 13
Correct Answer: D
Explanation:
2
What will be the largest value printed by the following code?
for (int x = 5; x > 0; x--)
for (int y = 0; y < 8; y++)
System.out.println (x*y);
A. 5
B. 8
C. 35
D. 40
E. 64
Correct Answer: C
Explanation:
3
Assume num and max are integer variables. Consider the code
While (num < max)
num++;
Which values of num and max will cause the body of the loop to be executed exactly once?
A. num = 1, max = 1;
B. num = 1, max = 2;
C. num = 2, max = 2;
D. num = 2, max = 1;
E. num = 1, max = 3;
Correct Answer: B
Explanation:
4
Which for loop is equivalent to this while loop?
int y = 5;
while (y >= 0)
{
System.out.println (y);
y--;
}
A. for (int y = 0; y < 5; y++)
System.out.println (y);
B. for (int y = 5; y > 0; y--)
System.out.println (y);
C. for (int y = 5; y >= 0; y--)
System.out.println (y);
D. for (int y = 0; y > 5; y++)
System.out.println (y);
E. for (int y = 0; y > 5; y--)
System.out.println (y);
Correct Answer: C
Explanation:
5
Which expression tests to make sure the grade is between 0 and 100 inclusive?
A. (grade <= 100) || (grade <= 0)
B. (grade <= 100) || (grade >= 0)
C. (grade < 101) || (grade > -1)
D. (grade <= 100) && (grade >= 0)
E. (grade >= 100) && (grade <= 0)
Correct Answer: D
Explanation:
1
In the following code, what value should go in the blank so that there will be exactly six lines of output?
for (int x = 0; x < _____; x = x + 2)
System.out.println ("-");
A. 5
B. 6
C. 10
D. 11
E. 13
Correct Answer: D
Explanation:
2
What will be the largest value printed by the following code?
for (int x = 5; x > 0; x--)
for (int y = 0; y < 8; y++)
System.out.println (x*y);
A. 5
B. 8
C. 35
D. 40
E. 64
Correct Answer: C
Explanation:
3
Assume num and max are integer variables. Consider the code
While (num < max)
num++;
Which values of num and max will cause the body of the loop to be executed exactly once?
A. num = 1, max = 1;
B. num = 1, max = 2;
C. num = 2, max = 2;
D. num = 2, max = 1;
E. num = 1, max = 3;
Correct Answer: B
Explanation:
4
Which for loop is equivalent to this while loop?
int y = 5;
while (y >= 0)
{
System.out.println (y);
y--;
}
A. for (int y = 0; y < 5; y++)
System.out.println (y);
B. for (int y = 5; y > 0; y--)
System.out.println (y);
C. for (int y = 5; y >= 0; y--)
System.out.println (y);
D. for (int y = 0; y > 5; y++)
System.out.println (y);
E. for (int y = 0; y > 5; y--)
System.out.println (y);
Correct Answer: C
Explanation:
5
Which expression tests to make sure the grade is between 0 and 100 inclusive?
A. (grade <= 100) || (grade <= 0)
B. (grade <= 100) || (grade >= 0)
C. (grade < 101) || (grade > -1)
D. (grade <= 100) && (grade >= 0)
E. (grade >= 100) && (grade <= 0)
Correct Answer: D
Explanation:
(0) Comments
Post a Comment