Q1. Given the code fragment:
What is the result?
A. 10 8 6 4 2 0
B. 10 8 6 4 2
C. An Arithmetic Exception is thrown at runtime
D. The program goes into an infinite loop outputting: 10 8 6 4 2 0. . .
E. Compilation fails
Answer: B
Q2. boolean log3 = ( 5.0 != 6.0) && ( 4 != 5);
boolean log4 = (4 != 4) || (4 == 4);
System.out.println("log3:"+ log3 + \nlog4" + log4);
What is the result?
A. log3:false log4:true
B. log3:true log4:true
C. log3:true log4:false
D. log3:false log4:false
Answer: B
Q3. which three lines are illegal?
A. line 3
B. line 4
C. line 5
D. line 6
E. line 10
F. line 11
G. line 12
H. line 13
Answer: CDH
Q4. Which two are Java Exception classes?
A. SercurityException
B. DuplicatePathException
C. IllegalArgumentException
D. TooManyArgumentsException
Answer: AC
Q5. Which two are valid instantiations and initializations of a multi dimensional array?
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Answer: BD
Q6. Given:
Which two declarations will compile?
A. int a, b, c = 0;
B. int a, b, c;
C. int g, int h, int i = 0;
D. int d, e, F;
E. int k, l, m; = 0;
Answer: AD
Q7. 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
Q8. Given:
What is the result?
A. box
B. nbo
C. bo
D. nb
E. An exception is thrown at runtime
Answer: A
Q9. Given:
Class A { }
Class B { }
Interface X { }
Interface Y { }
Which two definitions of class C are valid?
A. Class C extends A implements X { }
B. Class C implements Y extends B { }
C. Class C extends A, B { }
D. Class C implements X, Y extends B { }
E. Class C extends B implements X, Y { }
Answer: AE
Q10. A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the result?
A. Compilation fails.
B. The third argument is given the value null.
C. The third argument is given the value void.
D. The third argument is given the value zero.
E. The third argument is given the appropriate false value for its declared type.
F. An exception occurs when the method attempts to access the third argument.
Answer: A