• 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
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Methods which have been overrriden more than once

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Methods which have been overriden more than once cannot be
directly accessed.(RHE book page 179 in my edition, topic on overriding).
Can anyone give an example on this as I am not clear.
Thks
 
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's an example:
public class Shape{
public void draw(Graphics g){
return shape;
}
}
public class Circle extends Shape{
public void draw(Graphics g){
return Circle;
}
}
public class Oval extends Circle{
public void draw(Graphics g){
return Oval;
}
}
Okay, now the draw method from Shape has been overridden more than once: by the Circle class, and the Oval class. Any member from the Circle class could access Shape's draw method with super.draw(Graphics g). But no member from the oval class can access the draw method in Shape, but it could access the draw method from Circle with the super.draw(Graphics g). So for overridden methods, you can only directly access one up on the hierarchy. There is no way you can access more than one level up directly. I hope this helps. Let me know if you still have questions.
 
Hemal Mehta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool got it! Somehow teh words just confused me....
Thanks anyways.
 
Sometimes you feel like a nut. Sometimes you feel like a tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic