Multiple Choice
Consider the following class definitions. public class BClass {private int x; public void set(int a) {x = a;} public void print() {System.out.print(x) ;}} public class DClass extends BClass {private int y; public void set(int a, int b) {//Postcondition: x = a; y = b;} public void print() { }} Which of the following correctly redefines the method print of DClass? (i) public void print() {System.out.print(x + " " + y) ;} (ii) public void print() {super.print() ; System.out.print(" " + y) ;}
A) Only (i)
B) Only (ii)
C) Both (i) and (ii)
D) None of these
Correct Answer:

Verified
Correct Answer:
Verified
Q1: The superclass inherits all its properties from
Q2: To determine whether a reference variable that
Q4: A subclass can override public methods of
Q5: Suppose that the class Mystery is derived
Q6: Suppose that the class Mystery is derived
Q7: A subclass inherits all its data members
Q8: The classes Reader and Writer are derived
Q9: In Java, stream classes are implemented using
Q10: If a class implements an interface, it
Q11: Interfaces are defined using the reserved word