CS FundamentalsHardAccenture · GATE CS
A Square class extends Rectangle and overrides setWidth so that it also changes the height, breaking code that expects independent width and height. Which principle is violated?
- A. Liskov Substitution Principle
- B. Dependency Inversion Principle
- C. Single Responsibility Principle
- D. Interface Segregation Principle
Correct answer: A. Liskov Substitution Principle
A subclass must be usable wherever its base type is expected without breaking behaviour; Square surprises Rectangle clients.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- A control-flow graph has 20 edges, 16 nodes and 2 connected components. Using V(G) = E - N + 2P, what is the cyclomatic complexity?
- Commits A-B-C-D-E are on the shared main branch and already pushed. Commit C introduced a bug. What is the safest way to undo only C's…
- A module contains functions to print to screen, write to a file and send over a network; a flag argument decides which one runs. Which…
- A load balancer with 99.9% availability fronts two redundant servers (parallel), each with 90% availability. System works if the balancer…
- A mutation test run generated 40 mutants. 4 are equivalent mutants and 28 were killed. What is the mutation score, excluding equivalent…
- Branch main has commit A. Branch feature was created from A and has commits B and C. After git merge --no-ff feature on main, how many…