DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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" );
    >
    > }
    >
    > }
    >




Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links