Question 335 of 169
PCAP Object-Oriented Programming Practice Question
A Python class 'Shape' defines an abstract method 'area'. Subclasses 'Circle' and 'Square' implement 'area'. A function 'calculate_area(shape)' expects a 'Shape' instance. Which principle ensures that the function works correctly without knowing the specific subclass?
⚠ Common exam trap
Python Institute often tests LSP by presenting a scenario where a subclass overrides a method in a way that changes the expected behavior (e.g., raising an exception or returning a different type), and candidates mistakenly choose Interface Segregation or Dependency Inversion because they confuse 'substitutability' with 'abstraction' or 'interface design'.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Liskov Substitution Principle
The Liskov Substitution Principle (LSP) states that objects of a superclass should be replaceable with objects of its subclasses without affecting the correctness of the program. In this scenario, 'calculate_area(shape)' accepts a 'Shape' instance, and because both 'Circle' and 'Square' are proper subtypes that honor the contract of the 'area' method, the function works correctly regardless of which subclass is passed. This is the core of LSP: substitutability without side effects.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Interface Segregation Principle
Why it's wrong here
The Interface Segregation Principle (ISP) states that no client should be forced to depend on methods it does not use, advocating for many small, focused interfaces rather than a single general-purpose one. An abstract Shape class with a single area() method does not create a bloated interface that forces subclasses to implement irrelevant functionality. The violation in the scenario concerns subclass substitutability, not the granularity of the interface, so ISP is not the principle at play.
- ✓
Liskov Substitution Principle
Why this is correct
The Liskov Substitution Principle (LSP) asserts that any subclass must be able to replace its base class without altering the correctness of the program. When Shape declares an abstract area() method, it establishes a behavioral contract that every subclass must honor; if a subclass overrides area() with an incompatible return type, raises an unexpected exception, or changes invariants, it breaks substitutability. This is exactly the design concern addressed by LSP, making it the correct principle for the described scenario.
- ✗
Single Responsibility Principle
Why it's wrong here
The Single Responsibility Principle (SRP) states that a class should have only one reason to change, concerning the cohesion of its own methods and state. An abstract area() method on a Shape class does not introduce multiple responsibilities; it simply defines a contract for subclasses to implement. SRP is about internal class design and does not address the relationship between a base class and its derived types, so it is misapplied here.
- ✗
Dependency Inversion Principle
Why it's wrong here
The Dependency Inversion Principle (DIP) states that high-level modules should not depend on low-level modules, and both should depend on abstractions; it also says abstractions should not depend on details. While an abstract Shape class is indeed an abstraction, DIP primarily concerns the direction of dependencies between modules, not the behavioral substitutability of subclasses. The scenario is about ensuring derived shapes can replace their base class transparently, which is the domain of LSP, not DIP.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jun 30, 2026
This PCAP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCAP exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.