• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a question waiting to be cleared

 
Mellihoney Michael
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Float t=new Float(0.9F);
Float s=new Float(0.9F);
Double u=new Double(0.9);
which statements evaluates true?
A.s==t
B.s.equals(t)
C.s==u
D.t.equals(u)
[ February 10, 2003: Message edited by: Mellihoney Michael ]
 
Igor Zeta
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
t and s are equals but not ==.
the other is neither equals nor ==
 
Ramnath krishnamurthi
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s.equals(t) will work since
s.equals(t) will compare the values.
s == t will compare the objects in the heap.
s == u will generate a compilation error.
t.equals(u) are not equals since the values are different.
 
Mellihoney Michael
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks,so answer is B?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic