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 the difference between preemptive scheduling and time slicing? : Java thread
You can create a string object as string str = “abc”; why cant a button object be created as button bt = “abc”;? Explain
Difference between notify() method and notifyall() method in java?
What is the use of static methods?
How does the garbage collector works in java?
how to write a server program and sending the mails to the server using smtp protocol please help me
What is the char data type?
What is java virtual machine? Explain
Difference between ‘>>’ and ‘>>>’ operators in java?
What is the difference between declaration and definition in java?
What are autoboxing and unboxing? When does it occur?
What are wrapper classes in java?
What is heterogeneous in java?
How many types of threads are there in java?
Can a string be null?