Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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 The Software Craftsman this week in the Agile forum!
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 ]
Have you tried LearnNowOnline?
subject: About Wrapper classes.