Consider the following class definitions. public class BClass {private int x; public void set(int a) { x = a; } public void print() { }} 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 is the correct definition of the method set of the class DClass? (i) public void set(int a, int b) {super.set(a) ; y = b;} (ii) public void set(int a, int b) {x = a; y = b;}
A) Only (i)
B) Only (ii)
C) Both (i) and (ii)
D) None of these
Correct Answer:
Verified
Q22: Interfaces are defined using the reserved word
Q23: In the scenario described in the accompanying
Q24: If class Dog has a subclass Retriever,
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