• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

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.
 
You got style baby! More than this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic