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
Q6: In Java, polymorphism is implemented using late
Q21: What type of inheritance does Java support?
A)
Q22: A subclass can directly access _.
A) public
Q23: Based on the diagram in the accompanying
Q24: Based on the diagram in the accompanying
Q24: If class Dog has a subclass Retriever,
Q26: To determine whether a reference variable that
Q28: Composition is a "has-a" relationship.
Q29: Any new class you create from an
Q30: What is the correct syntax for defining
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