why abstract class will have a constructor?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a method to check if input string is palindrome?

778


how can you catch multiple exceptions in java?

756


What is stringjoiner ?

748


What is the main method java?

758


Will the compiler creates a default constructor if I have a parameterized constructor in the class?

817


What do you understand by looping in java? Explain the different types of loops.

802


Why enumeration is faster than iterator?

719


how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? Or extending thread class or implementing runnable interface. Which is better? : Java thread

807


Why stringbuilder is not thread safe?

776


Which is better stringbuilder or stringbuffer?

714


What ide should I use for java?

732


What is the purpose of skeleton and stub?

822


What is functional interface in javatpoint?

728


Explain methods specific to list interface?

750


What are the differences between path and classpath variables?

761