private method access confusion


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: private method access confusion

  1. #1
    prabhak Guest

    private method access confusion


    when i execute subtest class using java2 , the following code is
    running successfully and giving the output message " main executed" .
    how can a private method of superclass is being accessed in sub class?
    can anybody clarify me?
    -------------------------------

    public class subtest extends test {
    }


    class test {

    private static void main(String args[]) {

    System.out.println("main executed" );

    }

    }


  2. #2
    news.devx.com Guest

    Re: private method access confusion

    It's not a matter of inheritance. The Sun JVM itself
    doesn't require that the main method of a class be
    accessible. It can be private. There is debate
    on the Sun web site about whether or not this
    behavior is a problem. The JVM implementation
    does not seem to be in concordance with the Java
    Language Specification (section 12.1.4).

    See the bugs with IDs 4252539 and 4155575

    at

    http://developer.java.sun.com/develo...s/4155575.html

    and

    http://developer.java.sun.com/develo...s/4252539.html


    ---Russell Johannesson

    "prabhak" <pp_reddy@yahoo.com> wrote in message
    news:390499cc$1@news.devx.com...
    >
    > when i execute subtest class using java2 , the following code is
    > running successfully and giving the output message " main executed" .
    > how can a private method of superclass is being accessed in sub class?
    > can anybody clarify me?
    > -------------------------------
    >
    > public class subtest extends test {
    > }
    >
    >
    > class test {
    >
    > private static void main(String args[]) {
    >
    > System.out.println("main executed" );
    >
    > }
    >
    > }
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center