File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "About Wrapper classes." Watch "About Wrapper classes." New topic

About Wrapper classes.

Michael Zhang

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
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:
subject: About Wrapper classes.
It's not a secret anymore!