Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14

Chapter 7 quiz

10 questions · instant feedback after each answer.

1.

Which OOP pillar bundles data and methods into a single unit?

Correct answer: B. Encapsulation bundles data and methods into a single class unit.
2.

Which keyword defines a class in JavaScript?

Correct answer: B. The class keyword declares the blueprint for an object, containing a constructor and methods.
3.

What runs automatically when a new instance is created?

Correct answer: A. The constructor() runs when a new instance is created and assigns the initial property values.
4.

Which keyword creates an instance of a class?

Correct answer: C. The new keyword allocates memory and calls the constructor to initialise a fresh object.
5.

In a class, methods are shared by all instances via the...

Correct answer: B. Methods are defined once on the prototype and inherited by every instance — saving memory.
6.

Which function schedules smooth animation frames (~60fps)?

Correct answer: C. requestAnimationFrame() runs a callback before the next repaint, typically 60 times per second.
7.

In a game loop, what should happen before drawing each frame?

Correct answer: A. Call ctx.clearRect() to erase the previous frame, otherwise old drawings persist.
8.

Which keyword lets a child class extend a parent class?

Correct answer: B. class Boss extends Player {} — the child class inherits the parent properties and methods.
9.

Which OOP pillar means "same interface, different behaviour"?

Correct answer: C. Polymorphism lets objects of different types respond to the same method call in their own way.
10.

Which array method calls update() on every game object?

Correct answer: A. gameObjects.forEach(obj => obj.update()) updates every object in the array.