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

Explain how did the fourteenth and fifteenth amendment affect the deed Scott decision
JOSIE HAS 43 ANIMAL BOOKS AND 29 ART BOOKS . SHE PUTS ALL THE BOOKS ON 8 SHELVES . SHE PUTS THE SAME NUMBER OF BOOKS ON EACH SHELF HAW MANY BOOKS DOES JOSIE PUT
What is the slope of the line on the graph?
Please help me with this problem it is pair each of triangles are similar but not drawn to scale. Calculate any lettered lengths
how to transfer bookmarks to new computer
what fraction is equal to 0.98
4h+2i+3j-2h-i. ?? I dont get it? please help​
I only need to 2 that is shading in STT plz plz reply plz help plz plz help me plz help plz
After 2 years, $560 simple interest was owed on a loan of $7,000. Find the annual interest rate.
Processing an online survey could be done __________Gathering the data. A. before B. During C. After D. during and Before.​