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
posted
0
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
posted
0
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
posted
0
4 is wrong because you can't use instanceof to compare one reference to another.