+ 3
In simple words, a constructor cannot be inherited, since in subclasses it has a different name (the name of the subclass). class A { A(); } class B extends A{ B(); } You can do only: B b = new B(); // and not new A() Methods, instead, are inherited with "the same name" and can be used. As for the reason: It would not have much sense to inherit a constructor, since constructor of class A means creating an object of type A, and constructor of class B means creating an object of class B. You can still use constructors from A inside B's implementation though: class B extends A{ B() { super(); } }
26th Aug 2016, 5:45 PM
Agha Asad Khan
Agha Asad Khan - avatar