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 do you understand by the term wrapper classes?
What are inbuilt functions?
Write a program in java to find the maximum and minimum value node from a circular linked list.
Which object oriented concept is achieved by using overloading and overriding?
Can java list be null?
How many bytes are there?
What’s a deadlock?
What isan abstract class and when do you use it?
Is map ordered in java?
When is an object subject to garbage collection?
What is a flag value?
What is exception in java?
What causes memory leak in java?
How do I enable java in safari?
Can a class be declared as protected?