Java Programming - Java.lang Class - Discussion

Discussion Forum : Java.lang Class - General Questions (Q.No. 3)
3.
Which of the following are valid calls to Math.max?
  1. Math.max(1,4)
  2. Math.max(2.3, 5)
  3. Math.max(1, 3, 5, 7)
  4. Math.max(-1.5, -2.8f)
1, 2 and 4
2, 3 and 4
1, 2 and 3
3 and 4
Answer: Option
Explanation:

(1), (2), and (4) are correct. The max() method is overloaded to take two arguments of type int, long, float, or double.

(3) is incorrect because the max() method only takes two arguments.

Discussion:
4 comments Page 1 of 1.

Manoj kumar said:   1 decade ago
1, 2, 4 are correct. 3 is wrong because it has 4 int values, max can take only two arguments i.e., two int or float values.

Dasoju said:   1 decade ago
However in the 4th option, the arguments of type double and float, My doubt is how can we compare double with float?

Please suggest?

Thanks.
(1)

Reddy said:   1 decade ago
It will take only two arguments only.

Rakesh said:   1 decade ago
Then what about 3?

Number 3 is also a integer data type so this is also correct one.

Why it is wrong? can you give me explanation.

Post your comments here:

Your comments will be displayed after verification.