• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Duplicate Method Names

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This question may have been asked before. If so, just refer me to the appropriate discussion, What I'm really looking for is some reference to the JLS to explain the results or a clear, understandable explanation. Thanks in advance.


The result when you run this is "Goodnight, Dick". Why "Goodnight"?

 
Betty Reynolds
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, just disregard. This example is from the JLS, in the section about hiding versus overriding for static methods.
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Betty, this means you got the concept cleared right?
regds
maha anna
 
Betty Reynolds
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, since greeting is static the reference at compile time is used to determine what method to invoke as opposed to name which is determined at run time.
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. All static ones (var/methods)are determined at compile time itself. Also the 'private' ones (var/methods).
regds
maha anna
[This message has been edited by maha anna (edited April 15, 2000).]
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi. It's not clear to me why "Goodnight Dick" would appear after running this. I'm having some trouble making the distinction between compile-time information checking and run-time information checking. Many certification exam questions require that one know when a problem will arise at compile time versus run time. Unfortunately, these are the questions I seem to consistently get wrong! Can you help me with the distinction? Thanks!
-Matt
 
Betty Reynolds
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're right. There are a lot of areas that require knowledge of what happens at compile-time vs. run-time and vice versa (i.e, casting, overriding/hiding, checked and unchecked exceptions, etc). My advice to you is to search on keywords such as "hidden", "cast", "polymorphism" etc. There were a lot of good discussions on these areas in this site and you can pick up a lot of knowledge here.
Of course, if you have the time and the motivation, the best source for this information is the JLS.
[This message has been edited by Betty Reynolds (edited April 16, 2000).]
 
Matt Claflin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Betty - I'll give searching a shot!
-Matt
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic