Can a class inherit the constructors of its superclass?

Answer Posted / qim2010

No. A class cannot inherit constructor of its superclass but
can call the superclass constructor. If a class called
“SpecialPet” extends your “Pet” class then you can use the
keyword “super” to invoke the superclass’s constructor. E.g.

public SpecialPet(int id) {
super(id); //must be the very first statement in the
constructor.
}

To call a regular method in the super class use:
“super.myMethod( );”. This can be called at any line

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which is easier netbeans or eclipse?

614


What is lossy conversion in java?

565


Can we clone singleton object?

567


What is the instance of an object?

559


What is reflexive association?

1012






when you will synchronize a piece of your code? : Java thread

532


What is the difference between dom and sax parser in java?

538


What is bifunction in java?

682


Is null a keyword in java?

559


os is developed in c no java is more secured then c na why dont the os developed is developed using java

3527


What are void methods?

573


what is server side caching?

1611


How we can skip finally block of exception even if some exception occurs in the exception block in java?

528


What is a singleton puppy?

537


Why singleton is not thread safe?

570