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

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.81 :

Post by ETS User »

The option "The statement : new Resource().equals(new Resource()); will always return true." is correct as well. This is because the data variable in the Resource class will be initialized to the same value on object creation.

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

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

Post by admin »

The given explanation explains why it is not correct:
If you call new Resource().equals(new Resource()); from a class that is in com.enthu package, Rule 4 mentioned above will be applied and equals(Resource) method will be chosen, which will print true (because data contains same values in both). But if it is called from a class that is outside com.enthu package, there is only one method available - equals(Object ), which will be called. This method will print false because both the references are pointing to a different objects.
If you like our products and services, please help us by posting your review here.

Alan

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

Post by Alan »

Somehow the answer for admin is correct, however considering that the option is out of context is not possible to see it that way. Besides, the option "If two distinct Resource objects are considered to be equal, then their 'data' fields must have contained the same string value" is not valid considering the code in the question, additionally based on admin's response "But if it is called from a class that is outside com.enthu package, there is only one method available", it is not posible to agree with the stament "If two distinct Resource objects are considered to be equal, then their 'data' fields must have contained the same string value." outside the package.

Post Reply

Who is online

Users browsing this forum: No registered users and 229 guests