5. What is the printout of the following switch statement? char ch = \'a\'; swit
ID: 641722 • Letter: 5
Question
5. What is the printout of the following switch statement?
char ch = 'a';
switch (ch) {
case 'a':
case 'A':
System.out.print(ch); break;
case 'b':
case 'B':
System.out.print(ch); break;
case 'c':
case 'C':
System.out.print(ch); break;
case 'd':
case 'D':
System.out.print(ch);
}
a. ab
b. a
c. aa
d. abc
e. abcd
6. What is x after evaluating
x = (2 > 3) ? 2 : 3;
a. 5
b. 2
c. 3
d. 4
7. Analyze the following code.
int x = 0;
if (x > 0);
{
System.out.println("x");
}
a. The value of variable x is always printed.
b. The symbol x is always printed twice.
c. The symbol x is always printed.
d. Nothing is printed because x > 0 is false.
8. To declare a constant MAX_LENGTH inside a method with value 99.98, you write
a. final double MAX_LENGTH = 99.98;
b. double MAX_LENGTH = 99.98;
c. final MAX_LENGTH = 99.98;
d. final float MAX_LENGTH = 99.98;
Explanation / Answer
5) B
6) C
7) C
8) A
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.