Why declaring a private abstract method makes no sense??

Discussion in 'Java' started by Neroku, Feb 7, 2007.

  1. Neroku

    Neroku Guest

    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
     
    Neroku, Feb 7, 2007
    #1
    1. Advertising

  2. 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
     
    Robert Klemme, Feb 7, 2007
    #2
    1. Advertising

  3. Neroku

    Adam Maass Guest

    "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".
    >


    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
     
    Adam Maass, Feb 7, 2007
    #3
  4. Adam Maass wrote:
    > "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".
    >>

    >
    >
    > 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
     
    Mark Thornton, Feb 7, 2007
    #4
  5. Neroku

    Daniel Pitts Guest

    On Feb 7, 3:47 am, "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".
    >
    > 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.
     
    Daniel Pitts, Feb 7, 2007
    #5
  6. On 07.02.2007 21:09, Daniel Pitts wrote:
    > On Feb 7, 3:47 am, "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".

    >
    > 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
     
    Robert Klemme, Feb 7, 2007
    #6
  7. Neroku

    Chris Uppal Guest

    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");
    }
    }
    }
    ================
     
    Chris Uppal, Feb 8, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Debashish Chakravarty

    when GOTO makes sense.

    Debashish Chakravarty, Nov 29, 2003, in forum: C Programming
    Replies:
    45
    Views:
    1,084
    Dan Pop
    Dec 9, 2003
  2. Replies:
    1
    Views:
    367
    Peter Otten
    Aug 30, 2006
  3. Replies:
    11
    Views:
    646
    Crouchinho
    Sep 26, 2006
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,004
    Smokey Grindel
    Dec 2, 2006
  5. Jaco Naude
    Replies:
    8
    Views:
    677
    Paul N
    Sep 28, 2010
Loading...

Share This Page