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

instance of --> chapter four operators

 
timo corn
Ranch Hand
Posts: 68
MyEclipse IDE PHP Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


b=Boat is a vessel, but why is b2=Boat(also is-a vessel) instance of Toy?
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
timo corn wrote:why is b2=Boat(also is-a vessel) instance of Toy?

Because b2 is actually referring to a SpeedBoat (not just a Boat) and the SpeedBoat class implements the Toy interface.
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use of "Instance of" in java says -

Bascially, you check if an object is an instance of a specific class. You normally use it, when you have a reference or parameter to an object that is of a super class or interface type and need to know whether the actual object has some other type (normally more concrete).


Regards,
Dan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic