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 About Wrapper classes. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "About Wrapper classes." Watch "About Wrapper classes." New topic
Author

About Wrapper classes.

Michael Zhang
Greenhorn

Joined: Dec 03, 2002
Posts: 17
Consider the following variables definitions.
Float f1 = new Float("10F");
Float f2 = new Float("10F");
Double d1 = new Double("10D");
Which of the following yields a boolean value of true.
a)f1 == f2
b)f1.equals(f2)
c)f2.equals(d1)
d)f2.equals(new Float("10"))
ANS: b,d
c is incorrect. why answer c returns false?
dragon ji
Ranch Hand

Joined: Oct 31, 2002
Posts: 110
the equals method at wraper class will return true only if the argument is not null and is a same object that represents the same value as this object.


scjp 1.4<br />challenge haven't limit!
Abu Yoosuf
Ranch Hand

Joined: Nov 14, 2002
Posts: 33
The equals() method defined in the java.lang.Float class is copied below.

In order to return true for an equality check, first of all, the object must be an instance of class Float.
[ December 05, 2002: Message edited by: Abu Yoosuf ]
[ December 05, 2002: Message edited by: Abu Yoosuf ]
[ December 05, 2002: Message edited by: Abu Yoosuf ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About Wrapper classes.
 
Similar Threads
equals method
about Float and Double
equals()
equals method
Float and ==