• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

rhe Test Yourself Question #3

 
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
 
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.

 
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.
 
mister krabs
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.
 
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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!