Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rhe Test Yourself Question #3

 
Annmarie Ziegler
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question asks for valid signatures for main method entry point of an application. According to answers, the following is correct :
public static int main (String [] arg)
It appears that it doesn't work (compiles correctly, but doesn't run).
Am I missing something?
Thanks
 
Anil Vupputuri
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The question asks for valid signatures for main method entry point of an application. According to answers, the following is correct :
public static int main (String [] arg)

No way. The compiler considers this as method but not main method, which is entry point of an application. It shouldnt return any value in main method, should return void.

 
rajashree ghatak
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i agree with Anil.
the main method(which is the entry point for JVM) should not return anything and hence the return type should be void.
The main method with int as return type is a valid method signature but it is certainly not the entry point.
rajashree.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oddly enough, Annmarie and I compared our "Complete Java 2 Certification" books and my copy says that the above is legal and her copy says that it is illegal. This is test yourself, chapter 1, question 3 (page 26). We have the same edition except at the bottom of the copyright page, her book says:
"10 9 8 7 6 5 4 3 2 1"
and mine says:
"10 9 8 7 6 5 4"
What do other copies of the book say about this question?
BTW, we checked the errata from the web site and it didn't mention anything about this.
 
Umesh Joglekar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One ending in 4 is the third printing
One ending in 1 is i think first printing
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic