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
How many bytes is 255 characters?
Is a case study a method or methodology?
How can you generate random numbers in java?
What are the types of java languages?
How is a variable stored in memory?
What is the main use of generics in java?
When do we use synchronized blocks and advantages of using synchronized blocks?
Give me some null interfaces in java?
What an i/o filter in java programming?
Explain the difference between protected and default access.
What is exception in java?
Does unicode support all languages?
Is string thread safe in java?
What is indexof in java?
What is advantage of java?