• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

superclass use a method of its subclass?

 
sandy chauhan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can a Superclass use a method of its subclass if yes how.....?
 
Stuie Clarky
Ranch Hand
Posts: 98
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read about Java Inheritance, its fairly straightforward what the answer is though
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12100
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would a superclass know which sub-class method to use? Or if there even is a sub-class?

I am assuming you are talking about creating an instance of the superclass, not simply using a super-class reference variable that it pointing to a subclass instance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic