Can an abstract class have a main method in Java?
I'll answer
Earn 20 gold coins for an accepted answer.20
Earn 20 gold coins for an accepted answer.
40more
40more
Studied at the University of Toronto, Lives in Toronto, Canada.
So there's no problem. Abstract just means you can't instantiate the class directly. You can have constructors if you want - they might be needed for subclasses to initiate the object state. You can have static methods, including main() and they don't need an object so calling them is fine.Feb 23, 2014
2023-06-17 06:34:36
评论(499)
Helpful(122)
Helpful
Helpful(2)

Harper Collins
QuesHub.com delivers expert answers and knowledge to you.
So there's no problem. Abstract just means you can't instantiate the class directly. You can have constructors if you want - they might be needed for subclasses to initiate the object state. You can have static methods, including main() and they don't need an object so calling them is fine.Feb 23, 2014