• 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

OOP - Inheritance Question

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:
I have an ancestor class Top with a private int "i" (say 5) and a public getValue() function that returns the integer value "i";
I created a descendant class Next from the above class and re-declared and initialized a private integer variable "i" (say to 10). But no new getValue() function here, as it is inherited from the ancestor.
My question is how can i get to print the value of integer i in the Next class (10), without Overriding the getValue() method from class Top.
Is it possible to get 10 to print, other than directly accessing the variable or using a getValue() method at class Next?
Thanks
Madan
//Top.java

[This message has been edited by Cindy Glass (edited October 05, 2001).]
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a word, no.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
reply
    Bookmark Topic Watch Topic
  • New Topic