?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Floating Point (Double Data Type) Equality

APCSA-YMLPKS

Consider the following code segment:

double x = 12.4;
double y = x/3;
System.out.println(y*3 == x);

The above segment will output false because:

A

y*3 is evaluated as an int

B

there is a round-off error

C

there is an overflow error

D

double and int cannot be compared using ==

E

3 is not equal to x