O A https://bcinstructure.com/courses/1653813/quizzes/3556143/take Consider the
ID: 3916993 • Letter: O
Question
O A https://bcinstructure.com/courses/1653813/quizzes/3556143/take Consider the following class definitions. public class BClass t private int x public void set(int a) ( xa; public void print y public class DClass extends BClass private Int y public void set (int a, int b) //Postcondition: x a;y b; cwhot goes here?> public void print(x ) which of the following is the best definition of the set) method of the class Dclass, according to our suidelines? public void set (int a, int b) ( super.set (a) public void set (int a, int b) t y -bi chExplanation / Answer
SOLUTION:- (i) is correct
public void set(int a, int b)
{
super.set(a);
y = b;
}
Explanation:- Because the declaration of x is private in super class "Bclass" so it can not be accessed directly in sub class "Dclass" and method "set" accepts only one argument in super class so it will be overloaded. So we can say that option (i) is correct definition of set() method of the class Dclass.
=============================================================================
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.