Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1let a = new Pet('Rex'); let b = new Pet('Mia'); | Aa.speak(); b.speak(); | |
| 2a.name = 'Max'; console.log(b.name); | BChanging a's name does not change b's name, so b still prints Mia | |
| 3Objects from one class share the same method, but the result can differ because each has its own property values | CCreates two separate objects from the same Pet class | |
| 4One class can be used to build many objects, each with its own values | Db = 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'). | |
| 5let a = new Pet('Rex'); let b = a; b.name = 'Mia'; | Elet pets = [new Pet('Rex'), new Pet('Mia')]; | |
| 6let a = Pet('Rex'); let b = Pet('Mia'); | FThe new keyword is missing, so no objects are created from the class. It should be new Pet('Rex') and new Pet('Mia'). |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
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.const a = new Pet("Rex", 5);const p1 = new Pet("Rex");
const p2 = new Pet("Mia");const a = new Pet("Rex", 5);
const b = new Pet("Mia", 5);
a.energy = 1; // b.energy is still 5// Pet has a speak() method
const b = new Pet("Mia");
console.log(b.speak()); // Mia says hiconstructor(name) {
this.name = name;
}