File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Can anybody give an example for this.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Can anybody give an example for this...." Watch "Can anybody give an example for this...." New topic
Author

Can anybody give an example for this....

Manoj Mani
Ranch Hand

Joined: Mar 31, 2007
Posts: 65
b.eqials(c) can return false even if c.equals(b) returns true.


Impossible Is Often Untried.Its Time For Us To Change....
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hi Manoj,

Don't you think, it violates the symmetric contract of the equals() method.



What is symmetric contract?
For any reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.




Regards,
cmbhatt


cmbhatt
Manoj Mani
Ranch Hand

Joined: Mar 31, 2007
Posts: 65
Ya thats right?But......

Given that b and c refer to instances of wrapper classes, which two statements are true? (Choose two)
A. b.equals(b) returns true.
B. b.equals(c) returns the same result as b == c.
C. b.eqials(c) can return false even if c.equals(b) returns true.
D. b.equals(c) throws an exception if b and c are different wrapper types.
E. b.equals(c) returns false if the type of wrapper objects being compared are different.

Answer: B, C

Thats why i asked......
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can anybody give an example for this....
 
Similar Threads
Can the color for the disabled item be changed
WA #1.....word association
Private methods
URGENT - NEED HELP - Block Code
error in Marcus Green 2.