Which of the following statements is true?
I. If a method expects an argument of type int but it is called with an argument of type float, it will result in a compile or runtime error.
II. If a method doesn't return a value, then a return type doesn't need to be specified in the method definition.
III. The Math class random() method returns a double value in the range from 0 up to but not including 1.

Respuesta :

Answer:

Option I.

Explanation:

(I) Option (I). is true. If a class accepts different argument type and the argument type provided is different then it will throw a error. The argument type provided and the argument expecting has to match for the compilation of the program without an error. So, option (I) is true.

(II) Option (II). is false. If the method doesn't return any value then the method declaration contains [tex]void[/tex] as the return type.

(III) Option (III) is false. The method random() returns a double value with the number between 0.0 and 1.0 with 0.0 included in the range but 1.0 is not included in the range. The method returns value with positive side but not the negative side.