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

when would 2 hours and 30 minutes end if it starts at 10
can someone translate this spanish to english.
What can you design/develop to improve ice skating?
Which of these cities is farthest from the earthquake's center? O Hinche OJacmel O Saint-Marc O Port-de-Paix
Overall, what types of organisms benefit from the producers that capture energy from sun light and produce oxygen and sugar?.
URGENT what type of scavengers (heterotrophs) live in the twilight or Mesopelagic zone
17. The goal of deindustrializing Germany was a part of the Plan. A. Truman B. Marshall C. Morgenthau D. Five-Year
Need help for this equation
Pleaseee help me to solve this
A triangle was translated 4 units down. In the graph, which figure is the pre-image and which figure is the image? A. TriangleFGH is the image and TriangleABC