Last reviewed
Correct answer: B. A new class can be based on an existing class, gaining its attributes and methods
Explanation
Inheritance is a lookup rule before anything else. Base a new class on an existing one and Python remembers the parent: "if a requested attribute is not found in the class, the search proceeds to look in the base class. This rule is applied recursively if the base class itself is derived from some other class." That is the payoff: methods you never wrote are found by walking upward, so shared behaviour lives in one place and each subclass carries only its differences.
The other half is that you may disagree with the parent — "Derived classes may override methods of their base classes." Define one of the same name on the subclass and yours wins the search. Usually you want to extend the parent, not discard it: "An overriding method in a derived class may in fact want to extend rather than simply replace the base class method of the same name." That is what a super() call in your override buys you; omitting it from an initialiser is the classic half-built subclass.
The wrong options deny sharing, invent a one-class-per-file rule, or describe data loss Python never does.
Sources
“if a requested attribute is not found in the class, the search proceeds to look in the base class. This rule is applied recursively if the base class itself is derived from some other class.”
“Derived classes may override methods of their base classes.”
“An overriding method in a derived class may in fact want to extend rather than simply replace the base class method of the same name.”
Practise 3 questions on this topic
Take Python OOP — Timed Test (3 questions) — scored instantly, explanation for every question, no login.