File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes main() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "main()" Watch "main()" New topic
Author

main()

Wena Dollison
Greenhorn

Joined: Jul 03, 2002
Posts: 7
I've encountered a question from a sample exam and it says:
For a class to be executed in the command line, main() can have such modifiers: public, final and native.
I need some clarification about this. Why can a main() be native? What other modifiers can a main() method have?
Thanks in advance!
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
Originally posted by Wena Dollison:
I've encountered a question from a sample exam and it says:
For a class to be executed in the command line, main() can have such modifiers: public, final and native.
I need some clarification about this. Why can a main() be native? What other modifiers can a main() method have?
Thanks in advance!

Wena,
For the purposes of the exam, you should assume that
Section 12.1.4, Invoke Test.main, of the Java Language Specification is enforced by the JVM. In reality, many versions of the JVM do not enforce the JLS.
The compiler does not generate an error if you declare a main method that does not conform to the JLS. Instead, the JVM should enforce the rules at run time if you try to invoke the main method from the command line.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: main()
 
Similar Threads
main()
abstract/concrete methods and modifiers
Constructors and Access Modifiers
Can main( ) be declared as private
doubt in access modifier