| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice TestPractice Test
About Exam
hard
Integer Overflow and Type Casting
< Prev
Next >

Assume score1, score2, and score3 are integer variables that hold large values. Which of the following expressions correctly calculates the average of these three scores while avoiding potential integer overflow?

A

(score1 + score2 + score3) / 3

B

score1 / 3 + score2 / 3 + score3 / 3

C

(double)(score1 + score2 + score3) / 3

D

((double)score1 + score2 + score3) / 3

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

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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