• Post Reply Bookmark Topic Watch Topic
  • New Topic

Polymorphism  RSS feed

 
Saad Zahoor
Ranch Hand
Posts: 82
Android
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question :  in this case it should invoke the method which contain speed = 150 . But it is invoking 90 .Why ??

 
praveen kumaar
Ranch Hand
Posts: 461
22
Android Chrome Eclipse IDE Google App Engine Java Notepad Oracle Ubuntu Windows
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Field members are not polymorphic and the variable speedlimit in the honda3 class has not override the previous one but it has actually hide it.polymorphism is only applicable to instance methods(in java).in fact polymorphism also doesn't applies to static methods.regarding hiding fields and methods go through these links
hiding methods
hiding fields.

Praveen.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!