• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

About Wrapper classes.

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic