← ACARA Digital Technologies Years 9–10

One class, many objects

Each new Pet() makes a separate object from the same class. Every object has its own property values, but all of them share the same methods. Changing one object does not change the others.

Understanding One class, many objects in ACARA Digital Technologies Years 9–10

What it does: Both objects call the same speak method, but it uses this.name, so the output differs for each object. The Pet class is written once, and each new Pet() creates another object with different property values. A class is the template. The objects made with new are the actual things built from it. The method is shared, but this points to rex only, so only Rex's own age changes.

Common mistakes: JavaScript is case-sensitive, so new pet() does not match the class Pet. It should be new Pet("Rex"). The method name is misspelled. It must be constructor, otherwise it will not run each time new Pet() makes an object.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 743–781) and word search (Modules 743–809).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
const a = new Pet('Rex'); const b = new Pet('Mia'); How many Pet objects have been made?
One object with two namesTwo separate objects
Matches
let a = new Pet('Rex'); let b = a; b.name = 'Mia';
↓
b = a does not create a new object. Both variables point to the same object, so changing b also changes a. Use let b = new Pet('Mia').
Applying
Meanings
Term
new Pet()
Meaning
Each new Pet() makes a separate object from the same class. Every object has its own property values, but all of them share the same methods. Changing one object does not change the others.
Practice
class Pet {
Testing
Gaps
const a = Pet("Rex", 5);
Check Answer
Spots
1const rex = new pet("Rex");
2const mia = new Pet("Mia");

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Butterfly' badge — Branch Hopper, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. const a = new Pet('Rex'); const b = new Pet('Mia'); How many Pet objects have been made?
A. Two separate objects ✓
B. One object with two names
Each time you use new Pet(), JavaScript builds a brand new object from the class.
2. a.name = 'Max'; is run on the Rex object. What happens to b.name (the Mia object)?
A. It also becomes 'Max'
B. It stays 'Mia' ✓
Each object keeps its own property values, so changing one object does not change the others.
3. Which line makes a second, separate object from the Pet class?
A. const b = a;
B. const b = new Pet('Mia'); ✓
const b = a; only gives the same object a second name. new Pet() is what creates a new object.
4. Which statement about methods is true?
A. All objects made from the class share the same methods ✓
B. Each object needs its own different method written in the class
The method is written once in the class and every object made from that class can use it.
5. rex.speak() prints 'Rex says woof' and mia.speak() prints 'Mia says woof'. Why are the results different?
A. this refers to the object that called the method ✓
B. The two objects have different speak() methods
It is the same method, but this.name reads the name from whichever object calls it.

Match the Pairs

let a = new Pet('Rex'); let b = new Pet('Mia'); → Creates two separate objects from the same Pet class
a.name = 'Max'; console.log(b.name); → Changing a's name does not change b's name, so b still prints Mia
Objects from one class share the same method, but the result can differ because each has its own property values → a.speak(); b.speak();
One class can be used to build many objects, each with its own values → let pets = [new Pet('Rex'), new Pet('Mia')];
let a = new Pet('Rex'); let b = a; b.name = 'Mia'; → b = a does not create a new object. Both variables point to the same object, so changing b also changes a. Use let b = new Pet('Mia').
let a = Pet('Rex'); let b = Pet('Mia'); → The new keyword is missing, so no objects are created from the class. It should be new Pet('Rex') and new Pet('Mia').

Key Term

new Pet()
Each new Pet() makes a separate object from the same class. Every object has its own property values, but all of them share the same methods. Changing one object does not change the others.

Fill in the Blanks

1. const a = new Pet("Rex", 5);
Hint: Type the keyword that makes a fresh object from a class.
2. const p1 = new Pet("Rex"); const p2 = new Pet("Mia");
Hint: Type the class name, because both objects come from the same class.
3. const a = new Pet("Rex", 5); const b = new Pet("Mia", 5); a.energy = 1; // b.energy is still 5
Hint: Type the variable name of the one object being changed, so the other is unaffected.
4. // Pet has a speak() method const b = new Pet("Mia"); console.log(b.speak()); // Mia says hi
Hint: Type the shared method name that every Pet object can call.
5. constructor(name) { this.name = name; }
Hint: Type the keyword that refers to the object being created, so each object stores its own value.

Spot the Error

Question 1
A const rex = new pet("Rex");
B const mia = new Pet("Mia");
C console.log(rex.name);
Line A — JavaScript is case-sensitive, so new pet() does not match the class Pet. It should be new Pet("Rex").
Question 2
A class Pet {
B contructor(name, age) {
C this.name = name;
D this.age = age;
E }
F }
Line B — The method name is misspelled. It must be constructor, otherwise it will not run each time new Pet() makes an object.
Question 3
A class Pet {
B constructor(name) {
C name = name;
D this.energy = 5;
E }
F }
Line C — Without this, the value is not stored on the new object. It should be this.name = name; so each object keeps its own name.
Question 4
A const rex = new Pet("Rex");
B const mia = new Pet("Mia");
C rex.name = "Max";
D console.log(Pet.name);
Line D — Pet is the class, not one of the objects. To read Mia's own property value, use the object: mia.name. It is still "Mia" because changing rex does not change mia.
Question 5
A const p1 = new Pet("Rex");
B const p2 = Pet("Mia");
C p1.eat();
D p2.eat();
Line B — The new keyword is missing. A class must be called with new Pet("Mia") to create a separate object.

Student with a class code? Join your class →