why the abstract class has default constructor?

Answers were Sorted based on User's Feedback



why the abstract class has default constructor?..

Answer / 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

why the abstract class has default constructor?..

Answer / amandeep

A Abstract Class Can't Have An Default constructor........Cause It Can't Have An Instance Of It.....

Is This Answer Correct ?    2 Yes 10 No

Post New Answer

More Core Java Interview Questions

How to find the largest value from the given array.

0 Answers  


How do you compare characters in java?

0 Answers  


What Is Pointer?

4 Answers  


why are there separate wait and sleep methods? : Java thread

0 Answers  


Which number is denoted by leading zero in java?

0 Answers  






What happens when you assigned a 'double' value to a 'String'?

8 Answers  


What is the static import?

0 Answers  


What is use of valueof () in java?

0 Answers  


if a java file without any source code is valid java file?

3 Answers   SparkTG,


what is mutual exclusion? How can you take care of mutual exclusion using java threads? : Java thread

0 Answers  


What is a reflection package?

2 Answers  


all are saying java doesn't support multiple inheritance but by default Object class is super class for all the user defined classes and we can extend atmost one class so each class can extend more than one class so java supports multiple inheritance?i am confused with this,pls any one explain me.

8 Answers   CFG,


Categories