| preferred AP College board partner for AP classes
AP Computer Science A/Unit 1: Primitive Types
Start Practice TestPractice Test
About Exam
easy Solved by 5 students
Absolute Value and Casting to Round
< Prev
Next >

Assume double dnum has been correctly declared and initialized with a valid value. What is the correct way to find its absolute value, rounded to the nearest integer?

Assume double dnum has been correctly declared and initialized with a valid value. What is the correct way to find its absolute value, rounded to the nearest integer?

A

(int) Math.abs(dnum + 0.5)

B

Math.abs((int)dnum - 0.5)

C

(int) (Math.abs(dnum) + 0.5)

D

(int) Math.abs(dnum - 0.5)

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1braydenchoi111111 0m 00s 100
#2aaaa101 0m 01s -11
#3demosolasis101 0m 52s -62
#4parth.taur22701 1m 03s -73
#5richa.tuli11 4m 03s -143
#6lsj0803092213 2h 13m -7,927
Items per page:
10
1 – 6 of 6
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy