| preferred AP College board partner for AP classes
Login
 
Register
AP Computer Science A/Unit 2: Using Objects
Start Practice Test
Share
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

true
true

B

false
false

C

true
false

D

false
true

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