Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sub Class and super class

 
sonir shah
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Answer :
Show method is Test class
Show method in Q2 class
Show method in Test class
Show method in Q2 class
But in the main, we say : t=q and then t.show(), which means that it should print "Show method in Q2 class." and again in the second case,
we say q=(Q2)t, and then q.show(), which should print "Show method in TestClass."..
Where am I worng??
Sonir
 
bill williams
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because it is not 'overridden'.
<quote>
a subclass cannot override methods that are declared static in the superclass. In other words, a subclass cannot override a class method. A subclass can hide a static method in the superclass by declaring a static method in the subclass with the same signature as the static method in the superclass.
</quote>
 
bill williams
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instance variables are not 'overridden' either, just in case u might not know
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic