AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Declaring Multiple Variables in Class

APCSA-YEYEF4

Which of the following segments of code would correctly declare variables to store an employee’s name, age (in whole years), anniversary year, number of dependents, and spouse’s name?

I.

String emplName, String spouseName;
int age, int anniversary, int dependents;

II.

String emplName; String spouseName=null;
int age; int anniversary; int dependents=null;

III.

String emplName, spouseName;
int age, anniversary, dependents;
A

I only.

B

II only.

C

III only.

D

I and II only.

E

II and III only.