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 difference between wait and notify in java?
What is size () in java?
What kind of variables a class can consist of?
Do extraneous variables affect validity?
What are the uses of synchronized keyword?
What are the advantages of inner classes?
Explain why wait(), notify() and notifyall() methods are in object class rather than in the reading class?
How do you decide when to use arraylist and linkedlist?
What is volatile keyword in java
Is nan false?
What is compareto?
Can we have more than one package statement in source file ?
Why generics are used in java?
Explain spliterator in java8?
What is the difference between menuitem and checkboxmenu item?