Question: 1 Given: AnInterface is an interface. AnAdapter0 is a non-abstract, non-final class with a zero argument constructor. An Adapterl is a non-abstract, non-final class without a zero argument constructor, but with a constructor that takes one int argument. Which two construct an anonymous inner class? (Choose two.) A. AnAdapter1 aa = new AnAdapter1 () {} B. AnAdapter0 aa = new AnAdapter0 () {} C. AnAdapter0 aa = new AnAdapter0 (5) {} D. AnAdapter1 aa = new AnAdapter1 (5) {} E. AnInterface ai = new Anlnterface (5)) { Answer: B, D Question: 2 1. class A { 3. public String to String() { 4. return ?4?; 5. } 6. } 7. class B extends A { 8. public String toString() { 9. return super.toString() + ?3?; 10. } 11. } 12. public class Test { 13. public static void main (String[] args) { 14. System.out.printIn(new B()); 15. } 16. } What is the result? A. Compilation succeeds and 4 is printed. B. Compilation ????? is printed. C. An error on line 9 cause compilation to fail. D. An error on line 14 cause compilation to fail. E. Compilation succeeds but an exception is thrown at line 9. Answer: B Question: 3 Given: 1. public class Method Over { 2. public void set Var (int a, int b, float c) { 3. } 4. } Which two overload the set Var method? (Choose two.) A. private void set Var(int a, float c, int b) {} B. protected void set Var(int a, int b, float c) {} C. public int set Var(int a, float c, int b) {return a:} D. public int set Var(int a, int b, float c) {return a:} E. protected float set Var(int a, int b, float c) {return c:} Answer: A, C Question: 4 1. class A { 2. public byte file Number () { 3. return l; 4. } 5. } 6. 7. Class B extends A { 8. public short getNumber() { 9. return 2; 10. } 11. 12. public short getNumber() { 13. B b = new B(); 14. System.out.printIn(b.getNumber()); 15. } 16. } What is the result? A. Compilation succeeds and l is printed. B. Compilation succeeds and 2 printed. C. An error at line 8 cause compilation to fail. D. An error at line 14 cause complication to fail. E. Complication succeeds but an exception is thrown at line 14. Answer: C Question: 5 Given: 1. public class Foo { 2. public static void main(String[] args) { 3. StringBuffer a = new StringBuffer(?A?); 4. StrinbBuffer b = new StringBuffer(?B?); 5. operate (a, b); 6. System.out.printIn(a + ?,? + b): 7. } 8. static void operate (StringBuffer x, StringBuffer y) { 9. y.append(x); 10. y = x; 11. } 12. } What is the result? A. The code compiles and prints ?A,B?. B. The code compiles and prints ?A,BA?. C. The code compiles and prints ?AB,B?. D. The code compiles and prints ?AB,AB?. E. The code compiles and prints ?BA,BA?. F. The code does not compile because ?+? cannot be overloaded for StringBuffer. Answer: B Question: 6 1. public class X { 2. private static int a: 3. 4. public static void main (String [] args) { 5. modify (a) : 6. System.out.printIn(a) { 7. } 8. 9. public static void modify (int a) { 10. a++; 11. } 12. } What is the result? A. The program runs and prints ?0? B. The program runs and prints ?1? C. The program runs but aborts with an exception. D. An error ?possible undefined variable? at line 5 cause compilation to fail. E. An error ?possible undefined variable? at line 10 cause compilation to fail. Answer: A Question: 7 1. public class Test { 2. private static int j = 0; 3. 4. public static Boolean method B (int k) { 5. j + = k; 6. return true: 7. } 8. 9. public static void method A (int i) { 10. Boolean b; 11. b = I < 10 | method b (4): 12. b = I < 10 || methodb(8): 13. } 14. 15. public static void main (String args []) { 16. method A (0); 17. System.out.printIn(i); 18. } 19. } What is the result? A. The program prints ?0?. B. The program prints ?4?. C. The program prints ?8?. D. The program prints ?12?. E. The code does not compile. Answer: B Question: 8 Which two are equivalent? (Choose two.) A. 16 > 4 B. 16 / 2 C. 16 * 4 D. 16 >> 2 E. 16 / 22 F. 16 >>> 2 Answer: DF Question: 9 Given: 1. public class X { 2. public static void main (String [] args) { 3. byte b = 1277; 4. byte c = 126; 5. byte d = b + C; 6. } 7. } Which statement is true? A. Compilation succeed and d take the value 253. B. Line 5 contains an error that prevents compilation. C. Line 5 throws an exception indicating ?out of range? D. Line 3 and 4 contain errors that prevent compilation. E. The compilation succeed and d takes the value of 1. Answer: B Question: 10 Given: 8. int index = 1; 9. int[]foo = new int [3]; 10. int bar = foo [index]; 11. int baz = bar + index; What is the result? A. baz has a value of 0. B. baz has a value of 1. C. baz has the value of 2. D. An exception is thrown. E. The code will not compile. Answer: B End of Document