• Post Reply Bookmark Topic Watch Topic
  • New Topic

polymorphism........................  RSS feed

 
ssiva raman
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai,

i've a question regarding polymorphism.
is polymorphism possible only when the superclass is abstract?

give me some tips.....
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, there is no requirement that the superclass is abstract. Why do you think that?
 
Campbell Ritchie
Marshal
Posts: 56598
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The bit about extends Object is redundant, but it is a reminder that classes implicitly extend Object. If Object were abstract, you couldn't write new Object()
That code should give output similar to this:-
java.lang.Object@abce1234
Campbell
Ritchie

That shows the unoverridden and two overridden forms of toString, i.e. polymorphism where the superclass is not abstract.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!