KnowledgeBoat Logo
|

Computer Applications

Functions are the built-in modules that can be used in our program to perform a specific operation. There are some mathematical functions that are used for specific functions. For example, we can use Math.sqrt( ) function to return square root of a positive number, Math.random( ) and Math.ceil( ) to return random number in a range of numbers to return the next higher integer number.

Based on the above discussion, answer the following questions:

(a) What will be displayed, if the following statement is executed?
System.out.println(Math.sqrt(-25));

  1. Infinite
  2. -5.2
  3. NaN
  4. Logical error

(b) Math.random( ) function returns a random number in the range:

  1. between 0 and 1
  2. between -1 to 0
  3. between -1 to 1
  4. None of the above

(c) Which of the following function will return the next higher integer number?

  1. Math.max( )
  2. Math.min( )
  3. Math.floor( )
  4. Math.ceil( )

(d) Which of the following statement is true for Math.max( )?

  1. It will always result in int type value.
  2. It will always result in double type value.
  3. The resultant data type will depend upon the type of arguments.
  4. It will return float type, if arguments are double type.

Java Math Lib Methods

15 Likes

Answer

(a) NaN

(b) between 0 and 1

(c) Math.ceil( )

(d) The resultant data type will depend upon the type of arguments.

Answered By

8 Likes


Related Questions