Question: 1. What happens in the Java Virtual Machine (JVM) when the following line is processed? MyClass n = new MyClass(); A. Nothing, the line is
1. What happens in the Java Virtual Machine (JVM) when the following line is processed? MyClass n = new MyClass(); A. Nothing, the line is skipped, since no parameters are defined B. An object of type MyClass is created, no reference is created C. A reference to an object of type MyClass is created, no object is created D. Both a reference and an object of type MyClass are created 2. Which of the following is true? A. A single reference variable can refer to multiple objects at one time B. Multiple reference variables can refer to the same, single object C. An object can only be referred to by a single reference variable D. A reference variable always refers to a valid object 3. The class "Parent" and its subclass "Child" both implement a method with header: "public String printName()", printing "parent" and "child" respectively. Which of the 4 choices below reflects the correct output of the following program: Parent v1 = new Parent(); Child v2 = new Child(); Parent v3 = new Child(); System.out.println(v1.printName()+" "+ v2.printName()+" "+ v3.printName()); A. parent child child B. parent child parent C. parent parent parent D. child parent child 4. For the program in Q3 above, what are the types of variable v3 at the compilation time and at the run time? A. Parent Parent B. Parent Child C. Child Parent D. Child Child 5. In the programs in Q3 above, is the variable v2 a reference variable? A. Yes B. No 6. For the program in Q3 above, if the class Child implements another method with header: public void display(). And the class Child wants to call the method printName() in the class Parent from its own method public void display(), which of the following is correct? A. printName() B. this.printName() C. Parent.printName() D. super.printName()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
