wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes a question waiting to be cleared Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "a question waiting to be cleared" Watch "a question waiting to be cleared" New topic
Author

a question waiting to be cleared

Mellihoney Michael
Ranch Hand

Joined: Nov 27, 2002
Posts: 124
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 ]

a beginner in java
Igor Zeta
Ranch Hand

Joined: Nov 12, 2002
Posts: 40
t and s are equals but not ==.
the other is neither equals nor ==


ciao<br />Igor Zeta<br />SCJP1.4
Ramnath krishnamurthi
Ranch Hand

Joined: Jan 22, 2003
Posts: 56
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

Joined: Nov 27, 2002
Posts: 124
thanks,so answer is B?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: a question waiting to be cleared