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
Differentiate between nested and inner class in java.
How will you initialize an Applet?
Does java allow overriding static methods ?
What is the main use of java?
Can variables be used in java without initialization?
Can a vector contain heterogenous objects?
What is a blocking method in Java?
What is difference between path and classpath in java?
What is byte code and why is it important to java’s use for internet programming?
What is the difference between the paint() and repaint() methods?
Is node a data type in java?
What is the effect of keeping a constructor private?
What is difference between null and void?
How infinite loop is declared?
What is a boolean used for?