Can a class inherit the constructors of its superclass?
Answer Posted / gayathri
import java.io.*;
class Parent
{
Parent()
{
System.out.println("This is super class Constructor");
}
}
class Code3 extends Parent
{
Code3()
{
System.out.println("This is child class");
}
public static void main(String ar[])
{
Code3 c=new Code3();
}
}
Here if i call the child class constructor,even the parent class constructor is implicitly invoked,that means constructors can be inherited.
| Is This Answer Correct ? | 2 Yes | 2 No |
Post New Answer View All Answers
Why is a constant variable important?
How do you ensure that n threads can access n resources without deadlock?
Explain the scope of a variable.
Why do we use bufferedreader?
What is nan inf?
What data type is a string?
What is static class
What is difference between path and classpath in java?
What is hashset in java?
Which programming language is most secure?
Explain the protected field modifier?
What is the use of set in java?
How can a gui component handle its own events?
What is data string?
How do you compare characters in java?