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

What is a line break example?

576


What is the meaning of variable in research?

556


What is the difference between abstract class and interface1? What is an interface?

555


What is a line separator in java?

535


What are methods of a class?

540






What causes memory leaks in java?

490


What is the method in java?

593


Why vector is used in java?

555


How do you create a null object?

506


What is the role of the java.rmi.naming class?

519


What is try-with-resources in java?

609


How can you make sure that your singleton class will always return single instance in multi-threaded environment?

568


Can we sort arraylist in java?

557


What are actual parameters?

519


How will you compute size of a structure?

580