Java Reference
In-Depth Information
Review Questions
1.
Name the two control structures in Java used for making decisions.
2.
Name the three control structures in Java used for repetition.
3.
True or False: 2 + 2 = 4 “and” 5 - 3 = 1.
4.
True or False: 2 + 2 = 4 “or” 5 - 3 = 1.
5.
Which of the following data types can be used in a switch statement? Select all that
apply.
a. byte
b. int
c. float
d. String
e. char
f. boolean
6.
True or False: The value of each case in a switch statement must be either a final vari-
able or a literal.
7.
What is the output of the following code?
int k = 20;
while(k > 0)
System.out.println(k);
8.
What is the output of the following code?
int point = 15;
switch(point)
{
case 0 :
System.out.println(“point is 0”);
break;
case 15 :
System.out.println(“point is 15”);
case 30 :
System.out.println(“point is 15 or 30”);
break;
case 40 :
System.out.println(“point is 40”);
default :
System.out.println(“Invalid point”);
}
Search WWH ::




Custom Search