?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Boolean Fun with Integers

APCSA-GXL6NN

Consider the following code.

int n1 = 3001, n2 = 1062, n3 = 2250, n4 = 42;
boolean bool1 = n1 - n2 > n3;
boolean bool2 = !((""+n3).compareTo(""+n4)>0);
boolean bool3 = n3%2 == n1%2 + n2%2;
boolean bool4 = (n3+"").substring(2).compareTo((n2+"").substring(0,2))>0;
boolean bool5 = n1 + n4 < n2 + n3;

Which of the following boolean variables are initialized to true?

A

bool2, bool4, and bool5 only.

B

bool2 and bool5 only.

C

bool3, bool4 and bool5 only.

D

bool3 and bool5 only.

E

bool1, bool2, bool3, bool4 and bool5.