1.12 Objects: Instances of Classes
1. Exam Points
Distinguish class, object, attributes, behaviors.
Identify which variable contains/refers to which object.
- Example:
- Dog d1 = new Dog();
- Dog d2 = d1;
- here new is used only once, so only one object is created, d2 and d1 refers to the same object.
2. Knowledge Points
(1) Class
- A
class defines common attributes and behaviors of objects.
- An
object is a specific instance of a class with defined attributes.
- Example: Student(class) and Allen(a specific student)
- A class hierarchy (类层级结构) can be developed by putting common attributes and behaviors of related classes into a single class called a superclass (超类/父类), and then create subclasses(子类) using inheritance(继承).

- In this example, Animal, Bird, Fish make up a hierarchy, just like a father and his two sons.

- However,
implementing inheritance will not be covered in your AP CSA exam.
- All classes in Java are subclasses of the Object class.
A variable of a reference type holds an object reference.
Example:

3. Exercises