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
What is a line break example?
What is the meaning of variable in research?
What is the difference between abstract class and interface1? What is an interface?
What is a line separator in java?
What are methods of a class?
What causes memory leaks in java?
What is the method in java?
Why vector is used in java?
How do you create a null object?
What is the role of the java.rmi.naming class?
What is try-with-resources in java?
How can you make sure that your singleton class will always return single instance in multi-threaded environment?
Can we sort arraylist in java?
What are actual parameters?
How will you compute size of a structure?