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 Difference between instanceof and instanceOf 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 "Difference between instanceof and instanceOf" Watch "Difference between instanceof and instanceOf" New topic
Author

Difference between instanceof and instanceOf

Najmunnisa Sageer
Greenhorn

Joined: May 18, 2008
Posts: 9
Hi,

Can anyone help me to differentiate between instanceof and instanceOf operators.

I know that the instanceof operator is used for checking an object is of particular type and its used for object reference variables only and other one instanceOf ??

Thanks

Neju
Meena Ajay
Ranch Hand

Joined: May 28, 2008
Posts: 38

I have not read about instanceOf with a capital 'O'.I think we have only one instanceof operator.As you said, the instanceof operator is used to check if an object is an instance of a specific class or interface.


Cheers, Meena
OCPJP 6
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

and other one instanceOf ??

And where did you find the other one ?


SCJP, SCWCD.
|Asking Good Questions|
Sunil Belurgikar
Greenhorn

Joined: May 21, 2008
Posts: 14
instanceOf with capital O can be used as variable name.
Exam creators use this to confuse you.
instanceof is java keyword which checks if perticular object is instance of the type..


SCJP 1.6
Raphael Rabadan
Ranch Hand

Joined: Jul 05, 2008
Posts: 141
You might be doing whizlabs exam. It's there where I saw a questions like this. instanceOf isn't a keyword, you can use it as class name, variable name or anything.


SCJP Java 6 (98%) - Story, SCJA (88%) - Story
Najmunnisa Sageer
Greenhorn

Joined: May 18, 2008
Posts: 9
Hi,

I had a doubt when I was reading our Scjp Faq(under the topic:What are some potential trips/traps in the SCJP exam? )
Now its cleared.

Thanks to all of you.

Neju.
Ramakrishna Konanki
Greenhorn

Joined: Apr 18, 2008
Posts: 20
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

The question is actually about the difference between instanceof and instanceOf and not instanceof and .class/.getClass()...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Difference between instanceof and instanceOf