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 boolean example?
What Is Composition?
Is void a wrapper class?
What is difference between local variable and global variable?
What is java instanceof operator?
What is the purpose of the enableevents() method?
Where and how can you use a private constructor?
What are Normalization Rules? Define Normalization?
What does flag mean in java?
Can sleep() method causes another thread to sleep?
Java is pass by value or pass by reference? Explain
Is array passed by reference in java?
Is java a software?
I am a fresher and know core java, c languge, html, css etc if I am illegible for any job then send it on my email tatranakshay276@gmail.com
What loop means?