my dog learned polymorphism
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes instance of --> chapter four operators Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "instance of --> chapter four operators" Watch "instance of --> chapter four operators" New topic

instance of --> chapter four operators

timo corn
Ranch Hand

Joined: Oct 26, 2013
Posts: 68

b=Boat is a vessel, but why is b2=Boat(also is-a vessel) instance of Toy?

Stuart A. Burkett
Ranch Hand

Joined: May 30, 2012
Posts: 679
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

Joined: Jul 09, 2001
Posts: 1183
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).


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
I agree. Here's the link:
subject: instance of --> chapter four operators
It's not a secret anymore!