?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Easy

Variable Scope within a Method

APCSA-6KVVEL

Consider the following class.

public class Animal 
{
    private String type;
    private int age;
    private int weight;

    public Animal(String animalType, int animalAge, int animalWeight)
    {
        // code not shown
    }

    public String determineSpecies()
    {
        // code not shown    
    }
}

Which of the following variables used in this class can be referenced within the determineSpecies method?

I.   type
II.  animalAge
III. animalWeight
A

I only.

B

II only.

C

II and III only.

D

I, II, and III.

E

None of these variables can be referenced.