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 is java beans?
What is the static keyword?
What is the unit of plancks constant?
Discuss 2D arrays.
What is the purpose of the system class in java?
What is slash r?
What is the purpose of static methods and variables?
What do heavy weight components mean in java programming?
Write a java program to generate fibonacci series ?
What is pre increment and post increment in java?
Why stringbuilder is not thread safe in java?
explain copyonwritearraylist and when do we use copyonwritearraylist?
is there a separate stack for each thread in java? : Java thread
What is the difference between a static and a non-static inner class in java programming?
What is a class reference?