Ask Question

What method of the Math object can be used to return the largest value from the values that are passed to it?

Question 6 options:

the Math. max () method

the Math. ceil () method

the Math. pow () method

the Math. abs () method

+1
Answers (1)
  1. 18 September, 08:52
    0
    the Math. max () method

    Explanation:

    The java. lang. * package contains all the essential components needed for a JAVA program which involves numbers and all the operations done on the numericals.

    The java. lang. math class contains all the methods needed to perform mathematical operations on numerical values.

    All the methods in the question are discussed below with examples.

    Math. max () method

    java. lang. Math. max (double / int / float a, double / int / float b)

    This method returns the highest value from among the parameters passed to it.

    The syntax for the above is

    Numbers can be integers, float and double or long. The return type is the same as the parameters.

    Two values to be compared are passed as arguments and the higher value of them is returned.

    This function also accepts negative integers as parameters.

    Math. max (-9, - 2);

    Gives - 2 as the output.

    Math. max (0.34, 0.45)

    Gives 0.45 as the output.

    Math. ceil () method

    java. lang. Math. ceil (double / int / float a)

    This method returns the nearest greater whole number for the given number.

    Integer parameter returns an integer number.

    Math. ceil (7);

    Gives 7 as the output.

    Decimal number will return the nearest higher integer.

    Math. ceil (8.7);

    Gives 9.0 as the output.

    Math. ceil (-0.34)

    Gives - 0 as the output.

    Math. pow () method

    java. lang. Math. pow (double / float / int a, double / float / int b)

    The above method returns the result of a raise to the power of b.

    The first parameter is the base while the second parameter forms the exponent.

    Math. pow (2.3, 4.5);

    This calculates (2.3) ^4.5.

    Gives 42.44‬ as the output.

    Math. pow (2, 3);

    This calculates the value of 2^3.

    Gives 8 as the output.

    Math. abs () method

    java. lang. Math. abs (double a)

    This method returns non-negative value of the numerical parameter passed to it. Absolute of a number does not changes its value but changes the sign of a negative number. It returns the positive or negation of the negative input number.

    Math. abs (-0.1234)

    Gives 0.1234 as the output.

    Math. abs (12.34)

    Gives 12.34 as the output.

    These methods require java. lang. Math to be imported in the program.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What method of the Math object can be used to return the largest value from the values that are passed to it? Question 6 options: the Math. ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers