why the abstract class has default constructor?

Answer Posted / ranganathkini

A class has a constructor so that when an instance of the
class is created, the fields of the class can be setup to a
initial valid state.

Abstract classes define partial implementation of a public
contract. Which means that it may implement some of the
methods and contains partially implemented methods that are
marked abstract.

Since abstract classes can have partial implementation and
such partial implementation can include fields of the class,
a constructor becomes necessary so that those fields are
initialized to a valid default state when they are created
thru the constructor of their concrete subclasses.

Is This Answer Correct ?    12 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program in java to find the maximum and minimum value node from a circular linked list.

615


What does s mean in regex?

632


What are 3 data types?

635


Is 0 true or is 1 true?

597


What is number data type in java?

652






Is 0 true or false?

600


What is linked hashset and its features?

623


What are scriptlets?

668


Why we go for collections in java?

644


What are annotations in java?

729


Explain list interface?

602


Who developed java?

647


What type of language is java?

625


Explain about data types?

664


What is difference between fail-fast and fail-safe?

688