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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Byte class" Watch "Byte class" New topic

Byte class

Sridhar Srikanthan
Ranch Hand

Joined: Jan 08, 2003
Posts: 366
Hi all,
I found this question in Sreenivas Majji's Mock Exam question number 9.
The code is
The answer given is false. I checked it by running the answer given is correct. By viewing the question, my instincts led me to the option B(i,e B). Can someone explain how "==" and "equals()" work with Number class and its subclasses.
Thanks in advance
Sarma Lolla
Ranch Hand

Joined: Oct 21, 2002
Posts: 203
When ever a toString() method is called a new String object is created wrapping the value of the byte and returned by the system. So the two string objects are never equal in this case.
Sridhar Srikanthan
Ranch Hand

Joined: Jan 08, 2003
Posts: 366
Dear Sarma,
Thanks , I got it now
Consider Paul's rocket mass heater.
subject: Byte class
Similar Threads
Question from Majji's paper
Why this prints false?
Object Comparison
Doubt Regarding wrapper Class.
String Question