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
Can array grow dynamically in java?
What happens when you invoke a thread’s interrupt method while it is sleeping or waiting?
Is there any difference between nested classes and inner classes?
Where is core java used?
What is the final keyword in java?
Have you ever used hashtable and dictionary?
How can you read an integer value from the keyword when the application is runtime in java? example?
What are the types of java languages?
How do you find the absolute value?
What is the maximum length of a url?
Can vector have duplicates in java?
Is int primitive data type?
What are methods of a class?
How we can run a jar file through command prompt in java?
What is the latest version of java?