Quiz · Hard
SOLID, patterns, architecture, test design, Git workflows, CI/CD and secure practices.
Which SOLID principle says high-level modules should depend on abstractions?
Single responsibility
Open/closed
Liskov substitution
Dependency inversion
Depend on interfaces so implementations can be swapped and tested.
A class has one method for saving to a database, another for formatting reports and another for emailing. Which principle does it most clearly violate?
Interface segregation
Single responsibility
Liskov substitution
DRY
It has several unrelated reasons to change.
Which pattern notifies many dependents automatically when an object's state changes?
Singleton
Observer
Facade
Builder
Observer (publish/subscribe) decouples the subject from its listeners.
A payment service must support card, PayPal and bank transfer chosen at runtime. Which pattern fits best?
Strategy
Singleton
Iterator
Facade
Strategy encapsulates interchangeable algorithms behind one interface.
Which pattern gives a simple entry point to a complicated subsystem?
Adapter
Decorator
Facade
Command
A facade hides the complexity of many classes behind a simple interface.
What are the three parts of the MVC pattern?
Module, Variable, Class
Model, View, Controller
Method, Value, Constant
Master, Visitor, Client
Model holds data and logic, View presents it, Controller handles input.
Which is a major drawback of microservices compared with a monolith?
No independent deployment
Added distributed-system and operational complexity
They cannot scale
They require one language
Network calls, data consistency and operations become harder.
In TDD, what is the order of the cycle?
Green, red, refactor
Red, green, refactor
Refactor, red, green
Red, refactor, green
Write a failing test, make it pass, then clean up.
A field accepts ages from 18 to 65. Which set contains the best boundary test values?
20, 40, 60
17, 18, 19, 64, 65, 66
0, 100
18, 65 only
Boundary value analysis tests at and either side of each edge.
In the test pyramid, which layer should have the most tests?
End-to-end
Integration
Unit
Manual exploratory
Unit tests are fast and cheap, so they form the broad base.
What does a mock object do that a simple stub does not?
Returns canned values
Verifies that expected interactions happened
Persists data
Runs faster
Mocks assert on how they were called; stubs only supply responses.
What does git pull do?
Uploads commits
Fetches remote changes and merges them into the current branch
Creates a branch
Deletes remote branches
pull = fetch + merge (or rebase).
In the diagram, how many parents does the final commit Z' have?

0
1
2
3
A merge commit has two parents: Z and D.
Why should you avoid rebasing commits that others have already pulled?
It deletes the repository
It rewrites history, causing diverged copies and confusion
It is slower
It removes tags
Rebasing creates new commits with new hashes.
Which version bump signals a backward-incompatible API change under SemVer?
PATCH
MINOR
MAJOR
BUILD
MAJOR increments for breaking changes; MINOR for compatible features; PATCH for fixes.
In the CI/CD pipeline shown, which practice includes the build and test stages that run on each commit?
Continuous integration
Continuous monitoring
Manual QA
Capacity planning
CI automatically builds and tests every change.
A new version is released to 5% of users first and then widened if metrics stay healthy. What is this called?
Blue-green deployment
Canary release
Big bang release
Rollback
Canary releases limit the blast radius of a bad release.
What is the safest way to store user passwords?
Plain text in the database
Encrypted with a reversible key
Salted hash with bcrypt or Argon2
Base64 encoded
Slow salted hashes resist brute force; the original password is never recoverable.
Which refactoring statement is correct?
It adds new features
It changes behaviour to fix bugs
It improves internal structure without changing external behaviour
It removes all tests
Tests guard that behaviour stays the same.
Which UML diagram shows messages between objects ordered in time?
Class diagram
Use case diagram
Sequence diagram
Component diagram
Lifelines run vertically and messages are arrows ordered top to bottom.