• 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

Runtime Polymorphism

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

RunTime Polymorphism cannot be applied to static methods and variables



Can anybody explain what the above statement depicts?


Thanks in advance,
G.Sathish kumar
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

RunTime Polymorphism cannot be applied to static methods and variables



as static variables and methods are bound to class and not to objects, polymorphism is not possible.


Hope this helps
 
Sathish Kumar Govindan
Greenhorn
Posts: 18
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Dude
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Amit Ghorpade:

as static variables and methods are bound to class and not to objects, polymorphism is not possible.



Well, first, in Java (as in any other language I know), runtime polymorphism doesn't apply to member variables either.

Second, there are languages out there where classes are objects, too, and therefore class methods are also polymorphic. Just not in Java.
 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Ilja Preuss]:[...]in Java (as in any other language I know), runtime polymorphism doesn't apply to member variables either.

In Scala member values not explicitly declared private are inherited and overridable. As a matter of fact its a common idiom in Scala to eschew passing in arguments to a constructor in favor of creating an anonymous subclass and overriding specific values.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ilja Preuss


Second, there are languages out there where classes are objects, too, and therefore class methods are also polymorphic. Just not in Java


I am unaware about other OO languages, except Java and C++.
So I was talking in context of Java
[ June 15, 2008: Message edited by: Amit Ghorpade ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic