Can we inherit the constructor in a Class?please give one
example.
Answers were Sorted based on User's Feedback
Answer / sanketh
we cannot inherit constructors.
because if we declare a constructor it must be a same name
as its class name, but two class must have same name
Is This Answer Correct ? | 16 Yes | 4 No |
Answer / rakesh
We Can Not Interit the constructor.
We Can't have same class name
And Constructor Hava the same name as class name
Is This Answer Correct ? | 9 Yes | 2 No |
Answer / r.jainrocks@gmail.com
we can't inherit constructors because constructors are not the members of a class.
as in case of blocks.
Is This Answer Correct ? | 8 Yes | 2 No |
Answer / arvind patil
we cannot inherit the constructor.
But using the keyword super we can give a call
to the base class constructor
Is This Answer Correct ? | 6 Yes | 2 No |
Answer / praseen
We can not inherit the constructor in a class. Becoz we can't
have same class name. The constructor hava the same name as
of the class name.
Is This Answer Correct ? | 3 Yes | 2 No |
Answer / brijendra kumar(java xavient)
We connot inherit the constructor in class beause the
construtor name is same as the class name.
class Brijendra
{
int x,y;
Brijendra(int a , int b) //constructor of class
{
a=x;
b=y;
}
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / harivirat reddy
Constructors are not inherited because extending class must
contain diffent name but constructors class name and
constructor name must be similer.but we can inherit the
constructors by using 'super' keyword.
Is This Answer Correct ? | 3 Yes | 3 No |
Answer / amit
class demo
{
demo()
{
System.out.println("i am default constructor ");
}
}
class demo1 extends demo
{
demo1()
{
System.out.println("i am default constructor ");
}
}
class test
{
public static void main(String st[])
{
demo1 ob=new demo1();
}
}
but it is inherited constructor ....so be can say inherited constructor or/not ?????????
Is This Answer Correct ? | 0 Yes | 0 No |
What is a local block?
What are static blocks and static initalizers in java ?
What is the benefit of using enum to declare a constant?
Is java jre still free?
Why you should not use singleton?
Explain the difference between an Interface and an Abstract class?
What are the common uses of "this" keyword in java ?
Why we should declare the variables as static and final in interfaces?
When do we need to use internal iteration? When do we need to use external iteration?
Hi i am creating desktop application in that i want calling to mobile number. i have java telephone api (JTAPI) but i dont understand how it configure & use plese help me
Name few java util classes introduced with java 8 ?
How are observer and observable used in java programming?