Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+7 votes

When are "Math.abs", "Math.max", and "Math.min" the only examples of method overloading from the Math class?

asked in CSC211_Winter2018 by (863 points)

1 Answer

+2 votes
 
Best answer

Do your mean why are those the only examples of method overloading from the Math class....or at least the Math class methods we've discussed?

Of those we've discussed, those methods have more than one "version" of the method with different signatures. A different signature means they have a different number of parameters or different types of parameters or both.

For example, Math.abs has one version that accepts an integer parameter and returns an integer and another version that accepts a double parameter and returns a double. The headers for the methods are public static int abs(int a) and public static double abs(double a). The abs method actually has two other versions for floats and longs too.

You can Google Java Math class to see all of the methods of the Math class. In that list, you can see many methods that have more than one "version". Each of those methods is overloaded.

answered by (3k points)
selected by
0

I see what you're saying. I understand it now, thanks!

...