Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2013
    Posts
    108
    Rep Power
    0

    Default Why a static method cannot be overridden?

    Why is that a static method cannot be overridden?

    Just telling "static method cannot be overridden" makes it difficult to remember. Why it can't be overridden?
    Last edited by suhaas.mohandos@gmail.com; 08-17-2013 at 07:34 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default Re: Why a static method cannot be overridden?

    Simple. A static member isn't inherited, so it can't be overridden.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,733
    Blog Entries
    7
    Rep Power
    21

    Default Re: Why a static method cannot be overridden?

    Quote Originally Posted by suhaas.mohandos@gmail.com View Post
    Why is that a static method cannot be overridden?

    Just telling "static method cannot be overridden" makes it difficult to remember. Why it can't be overridden?
    A static method isn't associated with an object. You can call it as MyMethod.myMethod(). How should anyone or anything now that a sub class exists where this method is 'overridden'?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Subclass Overridden Method throws Exception Rule?
    By hemanthjava in forum New To Java
    Replies: 5
    Last Post: 05-14-2010, 03:20 PM
  2. Replies: 3
    Last Post: 02-09-2010, 06:22 AM
  3. Invoking a superclass version of a overridden method
    By CyberFrog in forum New To Java
    Replies: 3
    Last Post: 05-25-2009, 02:33 PM
  4. Replies: 1
    Last Post: 02-10-2009, 11:03 AM
  5. Replies: 1
    Last Post: 08-07-2007, 06:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •