aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Sun Sample exam: mistake?? 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 "Sun Sample exam: mistake??" Watch "Sun Sample exam: mistake??" New topic
Author

Sun Sample exam: mistake??

Alfred Kemety
Ranch Hand

Joined: Aug 14, 2002
Posts: 279
The question is:
What is the result?
A- x = 0
B- x = 1
C- x = 2
D- x = 3
E- x = 4
F- Compilation fails
The code is as follows: (note the private modifier of the main method)

The answer is:
Option E is the correct answer. The instance variable b is initialized to false, reset to false on line 8 and falls through to line 15, where x is set to 4.
If the main method was declared public then this answer should have been fine.. but since it's private, it will compile but will print "Main method not public."
Am I missing something???


Alfred Raouf - Egypt - SCJP 1.4<br />Kemety.equals(Egyptian) // returns true
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
We made a mistake on that question! It was never legal to mark the main method private, but it used to actually compile and run under some flavors of 1.3 (fixed in 1.4). Anyway, that sample question is being fixed to make the main method public.
cheers


Co-Author of <a href="http://www.amazon.com/exec/obidos/ASIN/0596007124/ref=jranch-20" target="_blank" rel="nofollow">"Head First Design Patterns"</a><br /> <br />Just a Jini girl living in a J2EE world.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Hi Kathy,
would you like to elaborate on that "we"?
Do you mean you're from "S...huuuush"?
-Barry
[ October 11, 2002: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sun Sample exam: mistake??
 
Similar Threads
q from sun's epractice exam
Boolean Question
fall - through for if-else loop ???
If condition
Garbage Collection