Java Reference
In-Depth Information
2. Which operator returns the remainder of a division operation?
a. /
b. %
c. ?
3. Which instance variable of an array is used to find out how big it is?
a. size
b. length
c. MAX_VALUE
Answers
1. a. In a do - while loop, the while conditional statement appears at the end of the
loop. Even if it is initially false, the statements in the loop are executed once.
2. b. The modulus operator (“ % ”).
3. b.
Certification Practice
The following question is the kind of thing you could expect to be asked on a Java pro-
gramming certification test. Answer it without looking at today's material or using the
Java compiler to test the code.
4
Given:
public class Cases {
public static void main(String[] arguments) {
float x = 9;
float y = 5;
int z = (int)(x / y);
switch (z) {
case 1:
x = x + 2;
case 2:
x = x + 3;
default:
x = x + 1;
}
System.out.println(“Value of x: “ + x);
}
}
Search WWH ::




Custom Search