Q1. given:
A. ns = 50 S = 125
ns = 125 S = 125
ns = 100 S = 125
B. ns = 50 S = 125
ns = 125 S = 125
ns = 0 S = 125
C. ns = 50 S = 50
ns = 125 S = 125
ns = 100 S = 100
D. ns = 50 S = 50
ns = 125 S = 125
ns = 0 S = 125
Answer: B
Q2. Given the code fragment:
nt a = 0;
a++;
System.out.printIn(a++);
System.out.printIn(a);
What is the result?
A. 1 2
B. 0 1
C. 1 1
D. 2 2
Answer: A
Q3. Which two items can legally be contained within a java class declaration?
A. An import statement
B. A field declaration
C. A package declaration
D. A method declaration
Answer: BD
Q4. Given the code fragment:
What could expression1 and expression2 be, respectively, in order to produce output –8, 16?
A. + +a, - -b
B. + +a, b-
C. A+ +, - - b
D. A + +, b -
Answer: D
Q5. Which two statements are true for a two-dimensional array?
A. It is implemented as an array of the specified element type.
B. Using a row by column convention, each row of a two-dimensional array must be of the same size.
C. At declaration time, the number of elements of the array in each dimension must be specified.
D. All methods of the class Object may be invoked on the two-dimensional array.
Answer: AD
Q6. Given the code fragment:
interface SampleClosable {
public void close () throws java.io.IOException;
}
Which three implementations are valid?
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Answer: ACE
Q7. Given:
What should statement1, statement2, and statement3, be respectively, in order to produce the result?
Shape: constructor
Square: foo
Shape: foo
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Answer: D
Q8. Given the code fragment:
What values of x, y, z will produce the following result?
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
A. X = 4, Y = 3, Z = 2
B. X = 3, Y = 2, Z = 3
C. X = 2, Y = 3, Z = 3
D. X = 4, Y = 2, Z = 3
E. X = 2, Y = 3, Z = 4
Answer: E
Q9. Given:
What is the result?
A. 2 1
B. 2 1 0
C. null
D. an infinite loop
E. compilation fails
Answer: E
Q10. Given:
What is the result?
A. 10 : 22 : 20
B. 10 : 22 : 22
C. 10 : 22 : 6
D. 10 : 30 : 6
Answer: B