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 | |
|---|---|---|
| 1Dog - name - age + speak() | AThe arrow points the wrong way. It should go from the child class Puppy to the parent class Dog. | |
| 2Puppy ──▷ Dog | BThe box is in the wrong order. A class diagram lists the class name first, then the attributes, then the methods. | |
| 3Turning a diagram box into code: the class name from the box becomes the class header | Cclass Puppy(Dog): | |
| 4Turning an inheritance arrow from Puppy to Dog into code: the parent class goes in brackets | Dclass Dog: | |
| 5Diagram box for Dog lists: Dog, speak(), name, age (methods before attributes) | EA class diagram box for Dog: the class name on top, then its attributes (name, age), then its methods (speak) | |
| 6Dog ──▷ Puppy (but the code says class Puppy(Dog):) | FAn inheritance arrow showing that Puppy is a child class that inherits from the parent class Dog |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
class diagram — A box listing a class's name, attributes and methods. An arrow joins a child class to the parent it inherits from. You draw it as a plan before writing the code.# Diagram box: Dog
class Dog:
pass# Arrow: Dog points to Animal
class Dog(Animal):
pass# Pet box has the attribute name
class Pet:
def __init__(self, name):# Pet box - method: speak()
class Pet:
def speak(self):# Arrow: Puppy points to Dog
class Puppy(Dog):
pass