my dog learned polymorphism*
The moose likes Beginning Java and the fly likes main() in abstract class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "main() in abstract class" Watch "main() in abstract class" New topic
Author

main() in abstract class

Krishna Tota
Ranch Hand

Joined: Mar 22, 2008
Posts: 40
Hi,
Can we write main() in an abstract class.
please explain in brief.
Thanks.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by Krishna Tota:
Can we write main() in an abstract class.


yes,we can write.

1.Abstract class can have concrete(non-abstract) methods.
2.Abstract class constructor is invoked when the first non-abstract class (which is extends abstract class)get instantiated
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Krishna Tota:
... Can we write main() in an abstract class...

How difficult would it be to test this?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

This may help:



You can execute ABS or Child..


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

This can be as simple as adding the word "abstract" to a HelloWorld program. (No instance of the class is required because main is static.)
 
 
subject: main() in abstract class
 
Similar Threads
can and any one this abstract and interface
Abstract Class vs. Interface
Diff bw Abstract class and Interface
abstract class(all abstract methods) vs interface
Mock test doubt?