Solved

Consider the Following Class Definitions

Question 27

Multiple Choice

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:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents