aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes instanceof query 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 "instanceof query" Watch "instanceof query" New topic
Author

instanceof query

geet kaur
Ranch Hand

Joined: Sep 03, 2008
Posts: 78
guys
do we check the type of the refernce varaible against the type provided on the right side of the operator or we just compare the object it is refering to?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

do we check the type of the refernce varaible against the type provided on the right side of the operator or we just compare the object it is refering to?


Obviously, it is checking the type of the actual object being referred to to a specific type. Checking the type of the reference variable is kinda silly -- as you can figure it out before you compile and replace the expression with a true or false.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
Don't get me started about those stupid light bulbs.
 
subject: instanceof query