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


Please Help Members By Posting Answers For Below Questions

What is java beans?

576


What is the static keyword?

592


What is the unit of plancks constant?

574


Discuss 2D arrays.

610


What is the purpose of the system class in java?

556






What is slash r?

545


What is the purpose of static methods and variables?

533


What do heavy weight components mean in java programming?

525


Write a java program to generate fibonacci series ?

574


What is pre increment and post increment in java?

502


Why stringbuilder is not thread safe in java?

572


explain copyonwritearraylist and when do we use copyonwritearraylist?

544


is there a separate stack for each thread in java? : Java thread

540


What is the difference between a static and a non-static inner class in java programming?

533


What is a class reference?

555