Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes A question from Mock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "A question from Mock" Watch "A question from Mock" New topic

A question from Mock

Ali Haider

Joined: Feb 21, 2001
Posts: 25
Why B is the correct Answer.
Q # 28).
What will happen if you invoke the following method?
1: public void check()
2: {
3: System.out.println(Math.min(-0.0,+0.0));
4: System.out.println(Math.max(-0.0,+0.0));
5: System.out.println(Math.min(-0.0,+0.0) == Math.max(0.0,+0.0));
6: }

A) prints -0.0, +0.0 and false.
B) prints -0.0, +0.0 and true.
C) prints 0.0, 0.0 and false.
D) prints 0.0, 0.0 and true.
Question is from Majji Exam. Any comments are welcome.
S Dave
Ranch Hand

Joined: Jan 28, 2001
Posts: 103
the ans is: b
ie, -0.0
-0.0 is considered to be equal to 0.0 in comparisons.
Ishaan Mohan
Ranch Hand

Joined: Jan 20, 2001
Posts: 115
The answer is b.
for Math.max() and Math.min -0.0 and +0.0 are different
for equality -0.0 is equal to +0.0
the output you get is -0.0, 0.0 ,true
Ali Haider

Joined: Feb 21, 2001
Posts: 25
Thankx to both of u...... I got it now
I agree. Here's the link:
subject: A question from Mock
It's not a secret anymore!