why abstract class will have a constructor?
Answers were Sorted based on User's Feedback
Answer / hari krishna
All the classes including the abstract classes can have
constructors.Abstract class constructors will be called
when its concrete subclass will be instantiated.
| Is This Answer Correct ? | 7 Yes | 1 No |
Answer / nitin panwar
Bcoz each subclass executes the superclass constructor
before executing own constructor,thats why abstract class
has a constructor .
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / aditya ganjiwale
Its there to be able to initialize the abstract class
internal state.
Lets say you would like to assign two variables, you would
have to do this for every implementation, but with
constructors in the abstract class you only need it once:
So every class inheriting only needs to call the
constructor, instead of assigning the values themself every
time.
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / ram
Abstract class have the constructor in it just to instantiate its instance variables. Where as Interfaces are not containing any instance variables. That is why, they dont have constructor concept.
| Is This Answer Correct ? | 0 Yes | 0 No |
can we declare private class in java file?
What is functional interface in javatpoint?
Why stringbuffer is faster than string?
What is the difference between import java.util.date and java .util?
How many types of JVM's (OR) Name of the JVM's which are used in Tomcat & Weblogic servers ?
Explain the importance of finalize() method.
Difference between this() and super() in java ?
What is callablestatement? How you can call stored procedure to pass in parameter?
When is finally block not called?
What is the char data type?
What is a conditional equation?
write a program to create an vector and listeterator.and value should be enter through keyboard.