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
Q31: Consider the following class definitions. public class
Q32: What type of inheritance does Java support?
A)
Q33: Suppose there are three classes named Shape,
Q34: Which of the following statements about the
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents