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
What is Applet Stub Interface ?
Can a class be protected in java?
What is thread safe singleton?
What is difference between char array and string?
What is an example of a constant variable?
What is the difference between replace and replace all?
Which list does not allow duplicates in java?
What is the purpose of the file class in java programming?
What’s the difference between callable and runnable?
What is boolean law?
Can a constructor have different name than a class name in java?
Is Constructor possible in abstract class in java ?
Can a static method be final?
Are functions objects in java?
Can we serialize singleton class?