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

what is the difference between @include page and @include file

2 Answers  


What are the limitations of procedural programming approach?

0 Answers   Amdocs,


What does the @override annotation do?

0 Answers  


What is meant by design patterns?

0 Answers  


How can an exception be thrown manually by a programmer?

0 Answers  






What is the need to implement Serializable interface (with no methods) for objects which are to be serialized ? We can write our own functionality which writes objects to streams then why we need to implement and tell JVM that which objects can be serialized.

6 Answers   iFlex, Sapient,


What is toarray method in java?

0 Answers  


What are the operands of instanceof operator?

3 Answers  


How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters?

0 Answers  


How do you sort a string in alphabetical order in java?

0 Answers  


what is filters and its use?

2 Answers   Virtusa,


What is a parameter in a function?

0 Answers  


Categories