ExamVeda
Login
Home
This question belongs to Java Program Inheritence
Inheritence
?

In Java, can a subclass inherit constructors from its superclass?

Answer & Solution
Correct Answer: Option D
Option A: Only if the subclass is marked as "final"

This option is incorrect. Marking a subclass as "final" means that it cannot be subclassed further, and it has no impact on the inheritance of constructors.

Option B: Yes, a subclass inherits constructors from its superclass

This option is incorrect. In Java, a subclass does not inherit constructors from its superclass. However, a subclass can call the constructors of its superclass using the super keyword.

Option C: Only if the superclass is marked as "static"

This option is incorrect. The "static" keyword cannot be applied to classes or constructors in a way that would affect inheritance.

Option D: None of the above

This option is correct. In Java, constructors are not inherited by subclasses. Subclasses must explicitly define their own constructors, although they can call their superclass's constructors using the super keyword.

Conclusion:

In Java, a subclass does not inherit constructors from its superclass, making Option D: None of the above the correct answer.
Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
Dinesh Todani
Dinesh Todani 2 years ago
No, constructors are not member of class so they can't inherited by subclass. please check your answer.