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
What are exceptions
What is empty list in java?
Do extraneous variables affect validity?
How many types of methods are there?
Write a function for palindrome and factorial and explain?
What is difference between final and immutable?
Explain about wait() method?
Can a class be private in java?
What are user defined exceptions?
How do you take thread dump in java?
Is string serializable in java?
Write a java program to generate fibonacci series ?
Is java hard to learn?
Tell some latest versions in JAVA related areas?
Does java vector allow null?