Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice TestPractice Test
About Exam
medium Solved by 2 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.8

B

7

C

7.3

D

8

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1sgarv251323 0m 00s 190
#2mali.nehme11 0m 00s 100
#3angelajxi1101 0m 00s -10
Items per page:
10
1 – 3 of 3
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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