Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Which of the following items regarding inheritance are true? and why? Select all

ID: 3725331 • Letter: W

Question

Which of the following items regarding inheritance are true? and why? Select all that apply.

A) the child class can call the grandparent constructor (assuming a grandparent exists) by using the super().super() syntax

B) child classes become abstract if abstract parent class methods are not defined in the child class

C) child classes can override but not overload parent class methods

D) the child class can change the access specifier for members of the parent class

E) the child class can be in a different package from the parent class.

F) the child class can be generic even if the parent is not generic

Answers:

A) the child class can call the grandparent constructor (assuming a grandparent exists) by using the super().super() syntax

B) child classes become abstract if abstract parent class methods are not defined in the child class

C) child classes can override but not overload parent class methods

D) the child class can change the access specifier for members of the parent class

E) the child class can be in a different package from the parent class.

F) the child class can be generic even if the parent is not generic

Explanation / Answer

Answer:

C, D, E, F

Explanation:

A) This option is wrong as super().super() is a wrong syntax. Suppose C class extends B and B class extend A. Then from C's constructor using super(), B's constructor can be called and from B's constructor using super(), A's constructor can be called.

B) If abstract parent class have abstract method and it is not implemented by child class the compilation error will come. So automatically child class never become abstract. To avoid error child class has to be abstract. So this option is also wrong

C) Child class can overload the parent class methods method so it is wrong.

D) This option is correct a child class can change the access specifier for members of the parent class. For example if class A has a private int variable. That can be defined public in child class.

E) The child class can be in a different package from the parent class. That means class A present in package1 and class B is present in package2. Then class B can extends class A, only thing class A has to be imported in class B using import package1.A syntax.

F)  Child class can be generic even if the parent is not generic. Also there can be different generic types for child and parent class. So this option is correct.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote