• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Enum - Constant Specific Class Body

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I expect the result : 800 100, because ICELANDIC has its own height.
But actually it is 800 13. Would someone explain this?
 
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Variables cannot be overriden by the subclasses and are always referred through the type of the reference rather than the instance of the reference.

In your case, ICELANDIC is an instance of subclass of Horse and others are just instances of Horse. However you are referring to all the instances through Horse type reference so variables value would be from Horse type (not based on the actual instance type). Check out these simple classes, and you might get some idea.



The output is


[ July 09, 2008: Message edited by: Santhosh Kumar ]
 
Faber Siagian
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Santhosh, great. Thanks.
 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice Question & great Reply ... thanks
I thought of playing with it a bit


[ July 10, 2008: Message edited by: neo Tux ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic
Similar Threads