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
Why are lists ordered in java?
What are the four versions of java?
Can we split string with in java?
What is floor math?
What is the purpose of the system class in java?
What if static is removed from main method?
Why is boolean important?
How can we find the sum of two linked lists using stack in java?
What is the purpose of a transient variable?
What are the different types of methodologies?
Which class contains a method: cloneable or object?
what is optional in java 8?
Suppose if we have variable ' I ' in run method, if I can create one or more thread each thread will occupy a separate copy or same variable will be shared?
What is oop principle in java?
Outline the major features of java.