Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

static method overriding

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


hi.. It is being said that static methods cant be overriden as static methods are methods of the class and doesnot belong to any object.
but at line 15 and line 24 static method defined in superclass is strictly obeying rules of overriding.

at line 15 its not letting declare any checked exception which is not defined in superclass method
at line 24 its not letting change only the return type as void is the subtype.


if static methods are methods of classes why am i not able to declare a method with same name but diffrenent return type or checked exception, why is the method behaving as if it were overriden.

thanks.
regards.
 
Ranch Hand
Posts: 44
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well your code currently does not compile for a different reason ... you have duplicate methods in your SubClass. You cannot define a method with the same name and argumnent list more than once in the same class.
However, if you only had 1 mymeth() method in your subclass ... then this question has been asked and answered before. Here is the LINK
Another concept you need to understand is overriding vs hiding. Read this ARTICLE for details.
 
arpit dhingra
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot for the link..
 
Everyone is a villain in someone else's story. Especially this devious tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic