OOP – constructor Method

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

OOP – constructor Method

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Does constructor() run automatically when a new instance is created?
A Yes
B No
2. Does 'this' refer to the instance being created inside constructor()?
A No
B Yes
3. Is 'Constructor' with a capital C valid JavaScript syntax?
A No
B Yes
4. Must 'new' be written in lowercase?
A Yes
B No
5. Can a constructor accept parameters like name or age?
A No
B Yes

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1constructor(name) { this.name = name; } Aconstructor(name) { ... }
2new Dog("Rex") BWrong - 'constructor' must be lowercase
3Refers to the new object being created inside a constructor CRuns automatically when a new Dog is created, setting name
4Runs automatically whenever a class is instantiated with new DCreates a new Dog instance and calls its constructor
5Constructor(name) { this.name = name; } Ethis
6let d = New Dog(5); FWrong - 'new' must be lowercase

Definitions

constructor

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
___________(name) {
2.
this.name = ____;
3.
let myDog = new Dog("___");
4.
___________(color) {
5.
this.color = _____;

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A Constructor(name) {
B this.name = name;
C }
Question 2
A constructor(name) {
B name = name;
C }
Question 3
A constructor(name) {
B this.name = name;
C ]
Question 4
A Constructor(age) {
B this.age = age;
C }
D let d = new Dog(5);
Question 5
A constructor(age) {
B this.age = age;
C }
D let d = New Dog(5);

Answer Key

OOP – constructor Method
Section A: Quick Questions
Q1
A — Yes
Q2
B — Yes
Q3
A — No
Q4
A — Yes
Q5
B — Yes
Section B: Match the Pairs
Q1
constructor(name) { this.name = name; } → Runs automatically when a new Dog is created, setting name
Q2
new Dog("Rex") → Creates a new Dog instance and calls its constructor
Q3
Refers to the new object being created inside a constructor → this
Q4
Runs automatically whenever a class is instantiated with new → constructor(name) { ... }
Q5
Constructor(name) { this.name = name; } → Wrong - 'constructor' must be lowercase
Q6
let d = New Dog(5); → Wrong - 'new' must be lowercase
Section C: Definitions
Q1
constructor — A special method inside a class that runs automatically when a new instance is created.
Section D: Fill in the Blanks
Q1
constructor(name) {
Q2
this.name = name;
Q3
let myDog = new Dog("Rex");
Q4
constructor(color) {
Q5
this.color = color;
Section E: Spot the Error
Q1
A — 'constructor' must be lowercase - a capital C causes an error.
Q2
B — Missing 'this.' before name - it should be this.name.
Q3
C — The block must close with }, not ].
Q4
A — 'constructor' must be lowercase - a capital C causes an error.
Q5
D — 'new' must be lowercase - a capital N causes an error.