About Question enthuware.ocajp.i.v7.2.994 :
Moderator: admin
About Question enthuware.ocajp.i.v7.2.994 :
Suggestion: It might be a good idea to post the content of the method WrapperType.equals(Object obj) to the explanation.
For example, equals() inside the class Interger is:
public boolean equals(Object obj) {
if (obj instanceof Integer) {
return value == ((Integer)obj).intValue();
}
return false;
}
This might make it easier to understand.
For example, equals() inside the class Interger is:
public boolean equals(Object obj) {
if (obj instanceof Integer) {
return value == ((Integer)obj).intValue();
}
return false;
}
This might make it easier to understand.
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.994 :
Thank you for your suggestion. This has now been added.
-Paul.
-Paul.
Re: About Question enthuware.ocajp.i.v7.2.994 :
Primitive is misspelled. I only say because I like this software and want it to do well. 

-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.994 :
Your feedback is very much appreciated. This has now been fixed.DusitnR wrote:Primitive is misspelled. I only say because I like this software and want it to do well.
-Paul.
-
- Posts: 5
- Joined: Wed Mar 27, 2013 11:57 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.994 :
what is the type of value to be returned? can you provide some more details?return value..
thank you
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.994 :
The type of return value is determined by the method declaration. If you specify boolean as the return type of the method, you have to return a boolean.
HTH,
Paul.
HTH,
Paul.
-
- Posts: 8
- Joined: Wed Dec 10, 2014 6:05 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.994 :
Doesn't "equals method can be overrided" aplly in this case?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.994 :
Not sure what you mean. Primitive wrapper classes already have their equals method defined. How will you change them?
-
- Posts: 38
- Joined: Thu Jan 07, 2021 2:47 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.994 :
Maybe I confuse something here but I find the way the question is written ambiguous.
It is not clear to me if "refer to instances of primitive wrapper classes" means:
a) there is one object of type a, one object of type b, etc.
or
b) all objects of type a, i.e. different objects of that class
I understood it as b) as which means that a.equals(a) would only be true if the same objects are referred to. I could, however, run equals on two different objects of the same class and would yield a false.
I would suggest to re-phrase the question saying "each refer to one particular instance of primitive wrapper classes". In that case it is clear.
It is not clear to me if "refer to instances of primitive wrapper classes" means:
a) there is one object of type a, one object of type b, etc.
or
b) all objects of type a, i.e. different objects of that class
I understood it as b) as which means that a.equals(a) would only be true if the same objects are referred to. I could, however, run equals on two different objects of the same class and would yield a false.
I would suggest to re-phrase the question saying "each refer to one particular instance of primitive wrapper classes". In that case it is clear.
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.994 :
There are different primitive wrapper classes - Byte, Short, Integer, etc.
The question quite clearly says that a , b, and c, could refer to instances of any of these classes. For eg. a might be referring to an Integer object, b might refer to a Short object and so on. a b and c are variables. Not objects.
Not sure what you find ambiguous in it.
The question quite clearly says that a , b, and c, could refer to instances of any of these classes. For eg. a might be referring to an Integer object, b might refer to a Short object and so on. a b and c are variables. Not objects.
Not sure what you find ambiguous in it.
Who is online
Users browsing this forum: No registered users and 3 guests