QUESTION 12 Given: 1. class Alligator { 2. public static void main(String[] args) { 3. int[] x[] = { { 1, 2 }, { 3, 4, 5 }, { 6, 7, 8, 9 } }; 4. int[][] y = x; 5. System.out.println(y[2][1]); 6. } 7. } What is the result? A. 2 B. 3 C. 4 D. 6 E. 7 F. Compilation fails. Solution : E
QUESTION 11 Given: 10. interface Data { public void load(); } 11. abstract class Info { public abstract void load(); } Which class correctly uses the Data interface and Info class? A. public class Employee extends Info implements Data { public void load() { /*do something*/ } } B. public class Employee implements Info extends Data { public void load() { /*do something*/ } } C. public class Emplo..
QUESTION 10 Click the Exhibit button. 1. public class A { 2. 3. private int counter = 0; 4. 5. public static int getInstanceCount(){ 6. return counter; 7. } 8. 9. public A(){ 10. counter++; 11. } 12. } 13. Given this code from Class B: A a1 = new A(); A a2 = new A(); A a3 = new A(); System.out.println(A.getInstanceCount()); What is the result? A. Compilation of class A fails. B. Line 28 prints t..
QUESTION 9 Given: 1. package geometry; 2. 3. public class Hypotenuse { 4. public InnerTriangle it = new InnerTriangle(); 5. 6. class InnerTriangle { 7. public int base; 8. public int height; 9. } 10. } Which statement is true about the class of an object that can reference the variable base? A. It can be any class. B. No class has access to base. C. The class must belong to the geometry package...
QUESTION 8 Given: 01. public class Hello { 02. String title; 03. int value; 04. 05. public Hello() { 06. title += " World"; 07. } 08. 09. public Hello(int value) { 10. this.value = value; 11. title = "Hello"; 12. Hello(); 13. } 14. } and: Hello c = new Hello(5);System.out.println(c.title); What is the result? A. Hello B. Hello World C. Compilation fails. D. Hello World 5 E. The code runs with no..
QUESTION 7 Which four statements are true? (Choose four.) A. Has-a relationships should never be encapsulated. B. Has-a relationships should be implemented using inheritance. C. Has-a relationships can be implemented using instance variables. D. Is-a relationships can be implemented using the extends keyword. E. Is-a relationships can be implemented using the implements keyword. F. The relations..