About Question com.enthuware.ets.scjp.v6.2.414 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
ETS User

About Question com.enthuware.ets.scjp.v6.2.414 :

Post by ETS User »

For the question: Which of the following statements is true?

The test said the correct answer was:
For any non-null reference o1, the expression (o1 instanceof Object) will always yield true.

I believe the correct answer is:
None of the above.

What if o1 was a primative? It won't compile...so it will not always yield true

I suppose if it's going to yield anything it would be true because in order for it to compile it would have to be an Object. My point is assuming it could be a primative, it will not always yield anything but a compiler error. Always is a big word.

I understand the point of the question and what concept it's testing but may I suggest that the question be revised to explain that o1 is not a primative or that it may yield true instead of always.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.414 :

Post by admin »

Hello,
If you have a statement like int o1 = 10; then yes, the given expression will not compile.
However, the question says "non null reference". In the above case (int o1 = 10; ) o1 is not a reference. A reference exists only for objects and not for primitives.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Guest

Re: About Question com.enthuware.ets.scjp.v6.2.414 :

Post by Guest »

Dang, thats the same mistake I made :(

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 55 guests