Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A Question from Marcus exam 3 about instanceof

 
Barkat Mardhani
Ranch Hand
Posts: 787
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 160
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 787
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
4 is wrong because you can't use instanceof to compare one reference to another.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic