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
How can we create an immutable class in java?
What is an image buffer?
what is the constructor and how many types of constructors are used in java?
How many bits is a string in java?
How many return statement are allowed in a function?
What is method overloading in JAVA? Why is it not present in C ?
Is static variable stored in heap?
Is linkedlist thread safe in java?
What is autoboxing in java?
Why is a singleton bad?
Give the hierarchy of inputstream and outputstream classes.
What are the states of thread in java?
What all methods are used to prevent thread execution ?
What restrictions are placed on method overriding in java programming?
How to reverse a string in java?