carriemariah1409 carriemariah1409
  • 14-07-2019
  • Computers and Technology
contestada

Which of the following would compile without error? A. int a = Math.abs(-5); B. int b = Math.abs(5.0); C. int c = Math.abs(5.5F); D. int d = Math.abs(5L);

Respuesta :

PhantomWisdom PhantomWisdom
  • 16-07-2019

Answer:

int a = Math.abs(-5)

Explanation:

Math.abs() is the function which gives the absolute value of the integer.

syntax:

Math.abs(int name);

the argument enter must be integer(int).

int b = Math.abs(5.0): here, 5.0 is not the integer, it is float. So, it gives error.

int c = Math.abs(5.5F): here, 5.5F is not the integer, it is float. So, it gives error.

int d = Math.abs(5L): L stand for long but it is not int. So, it also gives error.

Therefore, the correct result is int a = Math.abs(-5), -5 is integer.

Answer Link

Otras preguntas

What is the electronegativity difference that usually is the dividing line between covalent and ionic bonds?
Under the rule of the u.s. constitution, which remains in the hands of the states
In a certain club, the ratio of the number of boys to girls is 5:3. What percent of the members of the club are girls?
What is the solution for 3x-(2+4x)
What victorian problem does the speaker in matthew arnold's "dover beach" believe that he and his love can alleviate by being true to one another?
Which art category does this image most reflect? Explain your answer. (site 1)
What’s the answer for this question?
When would green plants carry out photosynthesis only during the day?
How do you multiply fractions?
If a person permanently damages a muscle through an accident, this injury may be inherited by his children. a. True b. False