• 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
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Dan's Exam - Return Types

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 !!!
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic