AP CSA 3.3 Exercise 2: Anatomy of a Class Applied Practice

Unit 3: Class Creation · Lesson 3.3 · Exercise 2

Anatomy of a Class: Applied Practice

Six scenarios on fields, methods and the difference between a class and one of its objects.

How this one is different

The exercise-1 editor asks you to write a class. These six ask what exists once per class versus once per object, which is the distinction every later topic builds on.

Applied Practice

6 questions · scenario driven · every answer is recorded for your teacher

Question 1 of 6Analyze
Three Dog objects are created from one Dog class, each with a different name.
How many copies of the name field exist?
Correct. Correct. The class is the blueprint; the objects are what hold data.
Incorrect. Fields exist and hold defaults from the moment the object is created.
Incorrect. Independent copies can hold entirely different values.
Incorrect. That describes a static variable, which is 3.7.
Question 2 of 6Apply
A class declares private int count; and never assigns it in the constructor.
What does a new object hold in count?
Incorrect. An int is never null.
Incorrect. Unassigned fields are legal.
Incorrect. Java does not expose uninitialized memory. Local variables, unlike fields, must be assigned before use.
Correct. Correct: 0 for numeric types, false for boolean, null for references.
Question 3 of 6Analyze
A method needs a temporary value used only while it runs.
Should that be an instance variable or a local variable?
Incorrect. Methods declare local variables routinely.
Incorrect. Persisting it makes it visible to every other method and turns a private detail into shared state.
Correct. Correct. A field should represent something the object IS, not scratch space.
Incorrect. The difference is lifetime and visibility, both significant.
Question 4 of 6Apply
A class defines a method but the program never creates an instance of the class.
Can that instance method be called?
Incorrect. Calling through the class name is how STATIC methods work, which is 3.7.
Correct. Correct. The object supplies the field values the method operates on.
Incorrect. Only main runs automatically.
Incorrect. Visibility does not remove the need for an instance.
Question 5 of 6Evaluate
Two objects of the same class are compared with == after being given identical field values.
What does the comparison report?
Correct. Correct, and it is the same reference-versus-content distinction that bites with Strings.
Incorrect. Comparing two references of the same type is legal.
Incorrect. Field count is irrelevant to reference identity.
Incorrect. Content comparison requires an equals method the class defines.
Question 6 of 6Apply
A class has fields, a constructor, and several methods.
What determines the ORDER these must appear in the file?
Incorrect. No such requirement exists.
Incorrect. The constructor may appear anywhere among the members.
Incorrect. A widespread convention, but not a rule the compiler enforces.
Correct. Correct. Members may reference each other regardless of declaration order.

Where to go next

Get in Touch

Whether you're a student, parent, or teacher — I'd love to hear from you.

Just want free AP CS resources?

Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]