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 io stream in java?
Do we have pointers in java?
Describe the term diamond problem.
What is the difference between java applets and applications?
Can we overload the constructors?
What is a functional interface?
Why java does not support pointers?
How to perform bubble sort in java?
Why is java called the platform independent programming language?
What is polymorphism java example?
what is the messsage u r going to get from an objectoriented programing?
java program with complete 4 oops concepts implemented example
Explain throw keyword in java?
Why charat is used in java?
What is the formula to calculate percentage?