• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why can't abstract class have abstract static method?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why can't abstract class have abstract static method?
 
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Deepak Patil Patil", please check your private messages regarding an important administrative matter.

Answer for your question is it is because abstract methods cannot be overridden.
This question has nothing to do with Servlets. I'm moving this to BJ forum.
 
Master Rancher
Posts: 4796
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Devaka Cooray wrote:Answer for your question is it is because abstract methods cannot be overridden.
This question has nothing to do with Servlets. I'm moving this to BJ forum.


I think Devaka meant to say that static methods cannot be overridden. (As explained in the link above.) Meanwhile abstract methods must be overridden. Thus, static methods and abstract methods are fundamentally incompatible.

Deepak: to understand this better, think about this: if a method is abstract, and there are two or more classes that override the method, how does the JVM decide at runtime which version of the method should be executed? And how would this work for a static method?
 
Devaka Cooray
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike Simmons wrote:I think Devaka meant to say that static methods cannot be overridden.


Yeah, it is - my mistake
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Regarding abstract static methods (as well as why interfaces can't have static methods), does not it all come down to method binding? Static methods, by design intent, are not to be associated with instances. So, I am betting the fathers of Java decided to go ahead and bind at compile time. As abstract methods have no known implementations at compile-time, there is nothing to bind to. I bet it was just a design decision to disallow "static polymorphism". Those are contradictory adjectives and concepts.
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch Masa Saito.
 
reply
    Bookmark Topic Watch Topic
  • New Topic