Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Why declaring a private abstract method makes no sense??

Reply
Thread Tools

Why declaring a private abstract method makes no sense??

 
 
Neroku
Guest
Posts: n/a
 
      02-07-2007
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

 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      02-07-2007
On 07.02.2007 12:47, Neroku wrote:
> 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
 
Reply With Quote
 
 
 
 
Adam Maass
Guest
Posts: n/a
 
      02-07-2007

"Neroku" <(E-Mail Removed)> wrote:
> 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


 
Reply With Quote
 
Mark Thornton
Guest
Posts: n/a
 
      02-07-2007
Adam Maass wrote:
> "Neroku" <(E-Mail Removed)> wrote:
>
>>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
 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      02-07-2007
On Feb 7, 3:47 am, "Neroku" <(E-Mail Removed)> wrote:
> 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.

 
Reply With Quote
 
Robert Klemme
Guest
Posts: n/a
 
      02-07-2007
On 07.02.2007 21:09, Daniel Pitts wrote:
> On Feb 7, 3:47 am, "Neroku" <(E-Mail Removed)> wrote:
>> 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

 
Reply With Quote
 
Chris Uppal
Guest
Posts: n/a
 
      02-08-2007
Mark Thornton wrote:

> > 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");
}
}
}
================


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to call virtual method in derived class from baseclass without declaring it abstract? Jaco Naude C++ 8 09-28-2010 09:37 PM
Using "abstract" on a class with no abstract method Stefan Ram Java 27 08-17-2009 12:36 AM
Abstract method in non-abstract class Chris Zopers ASP .Net 2 08-08-2008 11:40 AM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
About abstract class and abstract method Sameer Java 4 08-31-2005 12:59 AM



Advertisments