• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Dan Chisholm Mock 1 #19

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question 19

What is the result of attempting to compile each of the three class declarations and invoke each main method from the command line using jdk 1.4 or any jdk that is compliant with section 12.1.4 of The Java Language Specification?
a. Compiler error at line 2.
b. Compiler error at line 5.
c. Compiler error at line 8.
d. Run time error at line 2.
e. Run time error at line 5.
f. Run time error at line 8.
g. None of the Above
Answers are
Run time error at line 5. Run time error at line 8.
This code compiled and ran without any errors on my machine.
[ January 22, 2003: Message edited by: Jim Yingst ]
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy -- this has been corrected with version 1.4 of Java. So while it was never *supposed* to work (running a non-public main as THE main method), it still worked. That was basically a bug that they finally got around to fixing!
Which all goes to show, when in doubt trust the spec, even if it contradicts what you see in your own compiler or VM. So Dan's test is correct according to the spec, and according to the new (1.4) version.
cheers,
Kathy
 
Maria Garcia
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh ok. Thanks Kathy
 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Kathy!
reply
    Bookmark Topic Watch Topic
  • New Topic