File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About Wrapper classes.

 
Michael Zhang
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 110
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Abu Yoosuf
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic