********Will Constructor Participate in Inheritance??********
some told me it does.some told me it dont.
which is correct..pls help
Logics programing
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
********Will Constructor Participate in Inheritance??********
some told me it does.some told me it dont.
which is correct..pls help
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ismail SayyadRank #467 · 5.3K reputationPosted Oct 4, 2022, 8:03 AM EDT
Hello Jaya Prakash,
Construction cannot be inherited since the subclasses has different class name
For eg.
class A { A(); } class B extends A{ B(); } //since we can call B b = new b(); //But we cannot call B b = new A() //you can use construction A using extendUday DodiyaRank #239 · 10.3K reputationPosted Oct 4, 2022, 8:12 AM EDT
A subclass inherits all the members (fields, methods, and nested classes) from its superclass.
Constructors are not members, so they are not inherited by subclasses, but the constructor of the superclass can be invoked from the subclass.
For More Visit this https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html#:~:text=Constructors%20are%20not%20members%2C%20so,be%20invoked%20from%20the%20subclass.