why abstract class will have a constructor?

Answers were Sorted based on User's Feedback



why abstract class will have a constructor?..

Answer / hari krishna

All the classes including the abstract classes can have
constructors.Abstract class constructors will be called
when its concrete subclass will be instantiated.

Is This Answer Correct ?    7 Yes 1 No

why abstract class will have a constructor?..

Answer / nitin panwar

Bcoz each subclass executes the superclass constructor
before executing own constructor,thats why abstract class
has a constructor .

Is This Answer Correct ?    4 Yes 1 No

why abstract class will have a constructor?..

Answer / aditya ganjiwale

Its there to be able to initialize the abstract class
internal state.
Lets say you would like to assign two variables, you would
have to do this for every implementation, but with
constructors in the abstract class you only need it once:
So every class inheriting only needs to call the
constructor, instead of assigning the values themself every
time.

Is This Answer Correct ?    3 Yes 0 No

why abstract class will have a constructor?..

Answer / ram

Abstract class have the constructor in it just to instantiate its instance variables. Where as Interfaces are not containing any instance variables. That is why, they dont have constructor concept.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Hai all I want to print given array in reverse order Ex: int a[]={1,2,3,4,5};display this array in reverse order.

4 Answers  


What are the common problems you have faced while implementing Java?

1 Answers   IBM,


What are assertions in java?

1 Answers   Impetus,


What is the use of runnable interface?

0 Answers  


What modifiers are used with an inner class which is a member of an outerclass?

1 Answers  






why Interface used?

0 Answers   HCL,


How does compareto work in java?

0 Answers  


What is instance means in java?

0 Answers  


What is use of functional interface in java 8? Explain

0 Answers  


what is private constructor?what are the uses of writing private constructor in our program?

10 Answers  


What is an interface in java? Explain

0 Answers  


Why multiple inheritance is not supported by java?

0 Answers  


Categories