This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dan's Exam - Return Types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dan Watch "Dan New topic
Author

Dan's Exam - Return Types

Vijay Albuquerque
Ranch Hand

Joined: Feb 17, 2002
Posts: 42
The following question appears in Dan's Exam on Return Types:

The compiler ignores the semi-colon's after the method declaration statements. I cannot figure out why it ignores this !!!


Vijay Albuquerque
SCJP 1.4, SCWCD 1.3
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Vijay Albuquerque:
The compiler ignores the semi-colon's after the method declaration statements. I cannot figure out why it ignores this !!!

The compiler doesn't really ignore the semi-colon. That's a perfectly legal statement in Java. Try the following program:

You'll find that the program compiles and executes fine. A semi-colon by itself is simply an empty statement.
Corey


SCJP Tipline, etc.
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

Originally posted by Corey McGlone:
You'll find that the program compiles and executes fine. A semi-colon by itself is simply an empty statement.

Ok... so everything our dear Corey said BEFORE this statement was perfectly correct... and if by "the program" he means the lil tid bit of code that he plopped in his post -- he's right -- it will compile... but the code that Vijay posted will NOT compile -- not because of the stray ;'s (like Corey said -- those are legal) but because of some errors with return types.
Ya know -- those bartender-types think they're so smart... sometimes ya just gotta show 'em that they're wrong.

Corey McGlone is still my hero.
[ January 02, 2003: Message edited by: Jessica Sant ]

- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
Vijay,
The question is really about the return types. The semicolons are just typo errors.
The semicolons are viewed as empty statements and have no impact on the program. Even so, I'll remove them.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
 
Consider Paul's rocket mass heater.
 
subject: Dan's Exam - Return Types
 
Similar Threads
Question on Dan's Mock
Dan's Inner class question...
Dan's Mock Exam
Help on Dan's exam 1
Dan's questions : static variable