File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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: 18753
    
  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)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: instanceof query