Can an abstract class have a main method?
I'll answer
Earn 20 gold coins for an accepted answer.20
Earn 20 gold coins for an accepted answer.
40more
40more
Works at the International Development Association, Lives in Washington, D.C., USA.
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 09:11:10
评论(499)
Helpful(122)
Helpful
Helpful(2)

Sophia Wright
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