Can you have a constructor in abstract class?
Answer Posted / rajesh dangi
I don't understand why ppl start writing responses without
writing a small code to confirm it.
Guys an abstract class too can have a constructer. Any time
a class inheriting an abstract class is instantiated, its
constructer would first call the constructor of the
abstract class. Try it yourself.
Plus, the method in the abstract class with the same name
(i.e. its constructer) is always considered as a
constructer and not any regular method. Even when the
constructer is public, you can not invoke the constructer
of an abstract class in a sub class inheriting the abstract
class. That method can not be invoked by our code since it
is an abstract class and can not be instantiated by us
Is This Answer Correct ? | 62 Yes | 6 No |
Post New Answer View All Answers
Why singleton class is used in java?
What is use of super keyword?
How does compareto method work?
List out five keywords related to exception handling ?
What happens if main method is not static?
'A class is a template for an object' explain this statement.
What is difference between jdk,jre and jvm?
Which is bigger float or double java?
What is set in java?
How do you create a reference in java?
How do you create a bulleted list?
What is a control variable example?
What is the difference between compile-time polymorphism and runtime polymorphism?
What is return data type?
What are the advantages of exception handling?