| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice TestPractice Test
Share
About Exam
medium Solved by 5 students
Java Expression with Type Casting
< Prev
Next >

Consider the following code segment.

Scanner scan = new Scanner(System.in);
System.out.print("Enter a decimal number: ");
double value = scan.nextDouble();
int result = (int)(value + 0.5);

Assuming the user enters 7.3 as input, what value will be stored in the result variable after the code executes?

A

7.3

B

8

C

7.8

D

7

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1sgarv251323 0m 00s 190
#2mali.nehme11 0m 00s 100
#3angelajxi1101 0m 00s -10
Items per page:
10
1 – 3 of 3

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy