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

How can we create an immutable class in java?

576


What is an image buffer?

531


what is the constructor and how many types of constructors are used in java?

527


How many bits is a string in java?

565


How many return statement are allowed in a function?

453






What is method overloading in JAVA? Why is it not present in C ?

584


Is static variable stored in heap?

500


Is linkedlist thread safe in java?

551


What is autoboxing in java?

595


Why is a singleton bad?

549


Give the hierarchy of inputstream and outputstream classes.

604


What are the states of thread in java?

506


What all methods are used to prevent thread execution ?

543


What restrictions are placed on method overriding in java programming?

534


How to reverse a string in java?

513