?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Arithmetic Exception using Math Operations

APCSA-4PEMXJ

Consider the following code segments.

I.

double s = Math.sqrt(-100);

II.

int x = 0, y = 1000;
int average = y%x;

III.

double count = 0, sum = 1000;
double average = sum%count;

IV.

double num = Math.pow(-1, -1);

V.

int count = 0, sum = 1000;
int average = sum/count;

Which of these would throw an ArithmeticException?

A

I, II, and V only.

B

I and IV only.

C

II and V only.

D

I, II, III, and V only.

E

I, II, III, IV, and V.