Objects: Instances of Classes
Get introduced to instances of classes and the relationship between a class and an object.
We'll cover the following
It’s time to get an overview of object-oriented programming.
📌 Note: We’ll get into further detail in unit 5.
The class is a blueprint, or formal implementation of a data type, where objects are instances of such a class. Essentially, an object is a variable of the type defined by a class.
We can instantiate multiple objects of a class. For example, we can create as many String
type variables as we want.
Some examples of objects and classes
To better describe the relationship between a class and its objects, we can take a look at a few examples.
Example 1
If Dog is described as a class, its methods (behavior) may include fetching a ball, wagging its tail, or barking. However, your or your friend’s pet dogs are the objects of the class: Dog.
Get hands-on with 1400+ tech skills courses.