| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice Test
Share
medium Solved by 6 students
Integer Division and Type Casting
< Prev
Next >

Develop code to declare variables to store numbers and Boolean values.
Consider the following code segment:

int x = 7;
int y = 3;
double ratio1 = x / y;
double ratio2 = (double) x / y;
double ratio3 = x / (double) y;
boolean same12 = (ratio1 == ratio2);
boolean same23 = (ratio2 == ratio3);
System.out.println(same12);
System.out.println(same23);

What is printed as a result of executing this code segment?

A

false
true

B

true
false

C

false
false

D

true
true

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1kaisuki11 0m 00s 100
#2lsj0803092211 0m 23s 77
#3theofanusmischa11 1m 11s 29
#4y.seong202724 5m 11s -131
#5richa.tuli12 8m 49s -439
APFIVE © 2020.
Email: [email protected]|Privacy Policy