Solved

Consider the Following Class Definitions

Question 30

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