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 incompatible types in java?
Explain the scope or life time of class variables or static variables?
Are generics important java?
What are the new features in java 8? Explain
What is navigable map in java?
What is java and its types?
Why singleton class is used in java?
What is consumer in java?
Does java have a compiler?
How destructors are defined in java?
What are white spaces in java?
What is primitive data type in java?
Which is better singleton or static class?
What is java in layman terms?
What does it mean that a method or field is “static”?