B.S.W.E. Bachelor of Software Engineering Practice 3 — Questions and Answers
Question 1: Which software metric measures the percentage of source code executed by a test suite?
- Cyclomatic complexity
- Code coverage (Correct answer)
- Technical debt ratio
- Defect density
Correct answer: Code coverage
Code coverage measures what fraction of lines, branches, or paths are exercised by automated tests, helping identify untested code.
Question 2: A developer notices that three classes all duplicate the same 20-line validation logic. Which refactoring best addresses this?
- Inline Method
- Extract Superclass with shared method
- Replace Conditional with Polymorphism
- Move Method to a new shared utility class (Correct answer)
Correct answer: Move Method to a new shared utility class
Moving the duplicated validation to a shared utility class eliminates repetition and ensures a single point of maintenance for that logic.
Question 3: In agile sprint planning, what does 'velocity' represent?
- The number of developers on the team
- The average amount of work completed in past sprints (Correct answer)
- The total bugs fixed in the last release
- The number of stories in the backlog
Correct answer: The average amount of work completed in past sprints
Velocity is the average number of story points (or units of work) a team completes per sprint, used to forecast future delivery.
Question 4: Which design pattern allows new behaviors to be added to objects at runtime without altering their class?
- Factory Method
- Decorator (Correct answer)
- Singleton
- Bridge
Correct answer: Decorator
The Decorator pattern wraps objects in additional decorator objects, adding behavior dynamically while keeping the original class unchanged.
Question 5: What is the primary purpose of a staging environment in a software delivery pipeline?
- To store backup copies of production databases
- To mirror production for final validation before release (Correct answer)
- To run unit tests on developer machines
- To host documentation for end users
Correct answer: To mirror production for final validation before release
A staging environment replicates production conditions so teams can validate releases, run integration tests, and catch issues before going live.
Question 6: Which technique decomposes a monolithic system by assigning each bounded domain context to its own independently deployable service?
- Layered architecture
- Microservices architecture (Correct answer)
- Event-driven architecture
- Hexagonal architecture
Correct answer: Microservices architecture
Microservices architecture breaks a system into small services aligned to bounded contexts, each deployable and scalable independently.
Question 7: A pull request shows a method that catches a generic Exception and silently swallows it. What risk does this introduce?
- Lower cyclomatic complexity
- Hidden failures that become impossible to diagnose (Correct answer)
- Faster execution due to fewer logs
- Improved test coverage
Correct answer: Hidden failures that become impossible to diagnose
Swallowing exceptions hides errors silently, preventing logging, alerting, and proper error handling, making bugs extremely difficult to diagnose.
Which software metric measures the percentage of source code executed by a test suite?