Re: hi i have a query regarding inheritance



"vaibhav" <vaibhav.netkar@xxxxxxxxx> wrote in message
news:1171900504.902638.85730@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hey thanks a lot for the reply

making it private would not only make it inaccsseble directly in the
said class but also in all the other classes where it might be needed
but by doing so dont you think that it might take up a lot of memory
in some bigger programs and not inheriting it would also strenghten
the security concept in java

The inability to "un-inherit" members is pretty central to every OO
language I've ever seen. It may be an interesting idea, but I don't think
it's one that Sun wishes to explore with Java.


similarly also suppose

class abc
{
int a,b,c
public void display()
{......
}
}

class abcd extends abc
{
int d
public void display()
{......
}
}

class abcde extends abcd
{
int e
public void display()
{......
}
}

(base) class abc->(child) class abcd->(grandchild) class->abcde
all of them have public void display() method with same signature
through the object of class abcde(the grandchild class) can i invoke
display() method in class abc(base class) without invoking it in class
abcd(the child class) ???

Not really. You could add a protected method to abcd which simply
delegates to abc, and have abcde call that one, so that the code in
abcd.display() never gets invoked. But I can't think of a way to do it
without the cooperation of abcd. Maybe there's some crazy reflection-based
hack that I'm unaware of that'll let you do this.

- Oliver


.



Relevant Pages

  • Re: Roy Ratcliffes Java Splash Screen
    ... Both display the 'warning applet window' as expected, but NN clears, ... end and the splash frame to finalize. ... int displayTime) throws IOException { ... public void finish{ ...
    (comp.lang.java.gui)
  • Re: hi i have a query regarding inheritance
    ... int a,b,c ... public void display() ... class abcd extends abc ...
    (comp.lang.java.help)
  • JSplitPane and another issue
    ... public class MainPanel extends JPanel implements ActionListener { ... private WebBrowserPane browserPane; ... public void actionPerformed{ ... // Display the window. ...
    (comp.lang.java.gui)
  • JSplit Pane and another issue
    ... public class MainPanel extends JPanel implements ActionListener { ... private WebBrowserPane browserPane; ... public void actionPerformed{ ... // Display the window. ...
    (comp.lang.java.gui)
  • Re: display array in a frame wnd
    ... Some display are corresponding to several cameras (global ... void CDisplayImg::DrawToHDC ... void CDisplayImg::FillBitmapInfo(BITMAPINFO* bmi, int width, int height, ... int bpp, int origin) ...
    (microsoft.public.vc.mfc)