Two Laptop Bag*
The moose likes Mock Exam Errata and the fly likes Marcus Mock 1 Question 33 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "Marcus Mock 1 Question 33" Watch "Marcus Mock 1 Question 33" New topic
Author

Marcus Mock 1 Question 33

James Baud
Ranch Hand

Joined: Jan 06, 2001
Posts: 60
What will happen when you attempt to compile and run the following code?.
1) It will compile and the run method will print out the increasing value of i.
2) It will compile and calling start will print out the increasing value of i.
3) The code will cause an error at compile time.
4) Compilation will cause an error because while cannot take a parameter of true.

Answer:
3) The code will cause an error at compile time
The error is caused because run should have a void not an int return type.
My Comment: This code may compile if the return type is changed to void and the statement, return 1 removed, but I don't think it will run because there is no main method. My doubt is, is the main method and public class implied in this context?
------------------
~James Baud
He who asks, is a fool for five minutes;
but, he who does not ask, remains a fool forever. (Chinese proverb)


<B>~James Baud</B><P>He who asks, is a fool for five minutes;<BR>but, he who does not ask, remains a fool forever. (Chinese proverb)
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi James,
Yes
You have to assume that everything else needed to run the code example exists and is correct. Only analyze the snippet, as it's presented, to determine wether or not it will fail.
Hope that helps.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
James Baud
Ranch Hand

Joined: Jan 06, 2001
Posts: 60
Thanks Jane.
------------------
~James Baud
He who asks, is a fool for five minutes;
but, he who does not ask, remains a fool forever. (Chinese proverb)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Marcus Mock 1 Question 33
 
Similar Threads
Some Runtime vs. Compile Time SCJP 6.0 Mock Exam Questions
Question on Dan's Mock
Is the expression correct??
JQplus
java