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

What do you understand by the term wrapper classes?

534


What are inbuilt functions?

559


Write a program in java to find the maximum and minimum value node from a circular linked list.

506


Which object oriented concept is achieved by using overloading and overriding?

542


Can java list be null?

541






How many bytes are there?

530


What’s a deadlock?

601


What isan abstract class and when do you use it?

829


Is map ordered in java?

527


When is an object subject to garbage collection?

566


What is a flag value?

508


What is exception in java?

561


What causes memory leak in java?

470


How do I enable java in safari?

538


Can a class be declared as protected?

527