Question: Question 1 When we have code of the form: class A extends B { } o A and B are subclasses of each other. o
Question
When we have code of the form:
class A extends B
o A and B are subclasses of each other.
o A is a subclass of B
o A and B are unrelated.
o A and B are superclasses of each other.
o B is a subclass of A
Question
Inheritance is Choose the best answer.
o the same as composition
o an isa relationship between two classes
o a relationship between two data members in a single class
o a hasa relationship between two classes
o the same as aggregation
Question
When we have code of the form:
class A extends B
o A constructor in the B class can call any constructor in A by using the super keyword.
o A constructor in the A class can call any constructor in B but only by using the super keyword.
o Neither A nor B can have constructors.
o A constructor in the B class can call the default constructor in A by using the statement: B;
o A constructor in the A class can call the default constructor in B by using the statement: B;
Question
From a subclass, we can access Choose the best answer.
o Public and protected data members and methods of the superclass
o Any nonstatic data member of a superclass
o Any data member of the superclass
o Any static data member of a superclass
o Private data members and methods of the superclass
Question
When we have code of the form:
class A extends B
And we want class A to override a method named compute,
o we cannot have any methods in class A
o we cannot have any methods in class B
o we will have to add a method in class B named compute but we cannot have method named compute in class A
o we have to add methods named compute in class B with different numbers of parameters
o we will have to add a method in class A named compute with the same number of parameters as the one in B
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
