| preferred AP College board partner for AP classes
AP Computer Science A/Unit 1: Primitive Types
Start Practice TestPractice Test
About Exam
medium Solved by 26 students
Integer and Floating-Point Division
< Prev
Next >

Consider the following code segment.

int division = 22 / 7;
System.out.println("22 / 7 = " + division);

When executed, this code prints 22 / 7 = 3 because integer division is performed. Which of the following replacements for the first line of code will correctly perform floating-point division?

A

double division = double() 22 / 7.0 ;

B

double division = (double) (22 / 7) ;

C

double division = 22 / 7 ;

D

double division = 22.0 / 7;

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
#1angelajxi1111 0m 00s 100
#2l.alzahrani0411 0m 00s 100
#3songqiuhui201211 0m 06s 94
#4leftoverjluck11 0m 16s 84
#5kazvin.tjakradinata11 0m 17s 83
#6lsj0803092211 0m 33s 67
#710818526513 0m 25s 55
#8parth.taur22711 0m 52s 48
#9701704611 0m 57s 43
#10patrickmeijer00913 1m 09s 11
Items per page:
10
1 – 10 of 14

AI Tutor

How can I help?

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