This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


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 "A question from Mock" Watch "A question from Mock" New topic
Author

A question from Mock

Ali Haider
Greenhorn

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
true
-0.0 is considered to be equal to 0.0 in comparisons.
Ishaan Mohan
Ranch Hand

Joined: Jan 20, 2001
Posts: 115
Hi,
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
Greenhorn

Joined: Feb 21, 2001
Posts: 25
Thankx to both of u...... I got it now
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: A question from Mock
 
Similar Threads
confusion on (==)
Majji #Q.28
Math functions
double question in srinivas majji's mock exam
-0.0 == 0.0 ? help