Hello, I don't understand why a private abstract method declaration is
senseless, I do undersand why both declarations "final abstract" and
"static abstract" are senseless, but not so with "private abstract".
TIA
Robert Klemme - 07 Feb 2007 11:51 GMT
> Hello, I don't understand why a private abstract method declaration is
> senseless, I do undersand why both declarations "final abstract" and
> "static abstract" are senseless, but not so with "private abstract".
private methods cannot be overridden in subclasses.
robert
Adam Maass - 07 Feb 2007 15:40 GMT
> Hello, I don't understand why a private abstract method declaration is
> senseless, I do undersand why both declarations "final abstract" and
> "static abstract" are senseless, but not so with "private abstract".
A private member is visible only to the class that declares it.Specifically,
a private member is not visible to subclasses. An abstract method is a
method where a subclass is expected to provide the implementation. But a
subclass couldn't see the declaration of the signature if the signature were
private.
-- Adam Maass
Mark Thornton - 07 Feb 2007 19:50 GMT
>>Hello, I don't understand why a private abstract method declaration is
>>senseless, I do undersand why both declarations "final abstract" and
>>"static abstract" are senseless, but not so with "private abstract".
>
> A private member is visible only to the class that declares it.
It is also visible to nested/inner classes of the declaring class.
Mark Thornton
Chris Uppal - 08 Feb 2007 16:13 GMT
> > A private member is visible only to the class that declares it.
>
> It is also visible to nested/inner classes of the declaring class.
...and to any classes which enclose it.
But only in the sense that the compiler fakes access by generating non-private
backdoor access methods. That may be close enough for some purposes, but it
turns my stomach.
BTW, /inheritance/ as opposed to just /access/ is a different story. The
reader is invited to consider what the output of the following program should
be according to the spec, what it should be according to common-sense, and what
it will be according to the code generated by javac (I'm using JDK 1.6.0).
-- chris
================
public class Test
{
public static void
main(String[] args)
{
Nested n = new Nested();
n.test();
Test t = new Nested();
t.doIt();
}
private void
doIt()
{
System.out.println("Doin' it");
}
public static class Nested
extends Test
{
public void
test()
{
this.doIt();
super.doIt();
}
public void
doIt()
{
System.out.println("Not gonna do it");
}
}
}
================
Daniel Pitts - 07 Feb 2007 20:09 GMT
> Hello, I don't understand why a private abstract method declaration is
> senseless, I do undersand why both declarations "final abstract" and
> "static abstract" are senseless, but not so with "private abstract".
>
> TIA
a private method has the same properties as a final method, in that it
can never be overridden.
The super class can not see a private member of a derived class, and a
derived class cannot change the behaviour of any private methods in
the super class.
Robert Klemme - 07 Feb 2007 21:21 GMT
>> Hello, I don't understand why a private abstract method declaration is
>> senseless, I do undersand why both declarations "final abstract" and
>> "static abstract" are senseless, but not so with "private abstract".
>
> a private method has the same properties as a final method, in that it
> can never be overridden.
That's not exactly true - they do not have the same properties: you
cannot have methods with the same signature in subclasses the "final"
case. But you can with private - only those versions won't override the
superclass method.
> The super class can not see a private member of a derived class, and a
> derived class cannot change the behaviour of any private methods in
> the super class.
Exactly. Sorry for being picky, I guess you meant the right thing but
the wording seemed a bit off.
Kind regards
robert