About Question enthuware.ocajp.i.v8.2.1104 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
eddie3
Posts: 14
Joined: Sat Dec 17, 2016 10:17 pm
Contact:

About Question enthuware.ocajp.i.v8.2.1104 :

Post by eddie3 »

The answer to this question seems to be in contradiction with a a previous question from Ethuware (ocajp.i.v8.2,1369). In that question,

Code: Select all

Integer i1=1;
Byte b1 = 1;
Long g1= 1L;
The answer states that output to

Code: Select all

i1.equals(g1)
and

Code: Select all

i1.equals(b1)
are both false. And the explanation says that
The equals method of all wrapper classes first checks if the two objects are of the same class or not. If not, they immediately return false.
If this is the case, in this question,

Code: Select all

Integer i = new Integer(42);
Long ln = new Long(42);
Double d = new Double (42.0);
shouldn't

Code: Select all

i.equals(d);
or

Code: Select all

d.equals(ln)
both return false? Because they are all pointing to objects of different data types?

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

Re: About Question enthuware.ocajp.i.v8.2.1104 :

Post by admin »

Yes, both will return false. But they are valid code fragments, which is what the question is asking. It is not saying that they will return true.
I have updated the problem statement to make it clear.

thank you for your feedback!
Paul.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests