aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes A Question from Marcus exam 3 about instanceof Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "A Question from Marcus exam 3 about instanceof" Watch "A Question from Marcus exam 3 about instanceof" New topic
Author

A Question from Marcus exam 3 about instanceof

Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
Question 6).
Which of the following statements are true?
1) The instanceof operator can be used to determine if a reference is an instance of a class, but not an interface.
2) The instanceof operator can be used to determine if a reference is an instance of a particular primitive wrapper class
3) The instanceof operator will only determine if a reference is an instance of a class immediately above in the hierarchy but no further up the inheritance chain
4) The instanceof operator can be used to determine if one reference is of the same class as another reference thus

The answer is:
2) The instanceof operator can be used to determine if a reference is an instance of a particular primitive wrapper class

I thought 4 is also a true statement?
Brian Joseph
Ranch Hand

Joined: May 16, 2003
Posts: 160
Mm, I'm having trouble understanding number 4, and is it cut off?? Maybe all they're asking is if you can do this:

[ June 17, 2003: Message edited by: Brian Joseph ]
Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
Hi Brian,
No it is not cut off. That is how much was there.
Now i understand it. instanceof operators takes a reference and a class and tells if reference is of that class type. It does not take two references and checks if they both blong to same class.
Thanks
Barkat
[ June 17, 2003: Message edited by: Barkat Mardhani ]
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
4 is wrong because you can't use instanceof to compare one reference to another.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A Question from Marcus exam 3 about instanceof
 
Similar Threads
instanceof??
Test Question - Explanation?
instanceof Marcus Mock 3 No. 6
Using instanceof operator
instanceof operator