BCS Software Engineering Principles 2 — Questions and Answers
Question 1: What is the purpose of unit testing?
- Testing the entire application as a whole
- Testing individual components or functions in isolation to verify they work correctly (Correct answer)
- Testing performance under load
- Testing the user interface
Correct answer: Testing individual components or functions in isolation to verify they work correctly
Unit testing verifies that individual functions, methods, or components work correctly in isolation, catching bugs early in the development process.
Question 2: Which design pattern separates object construction from representation, allowing the same construction process to create different representations?
- Singleton pattern
- Observer pattern
- Builder pattern (Correct answer)
- Decorator pattern
Correct answer: Builder pattern
The Builder pattern separates the construction of a complex object from its representation, allowing different representations to be created through the same process.
Question 3: In object-oriented programming, what is encapsulation?
- Inheriting properties from a parent class
- Bundling data and methods that operate on that data within a class, restricting direct access from outside (Correct answer)
- Creating multiple implementations of the same interface
- Overriding parent class methods
Correct answer: Bundling data and methods that operate on that data within a class, restricting direct access from outside
Encapsulation bundles data (attributes) and methods together in a class and restricts external access using access modifiers (private, protected, public).
Question 4: What is refactoring in software development?
- Rewriting an application from scratch
- Restructuring existing code without changing its external behavior to improve readability or reduce complexity (Correct answer)
- Adding new features to existing code
- Fixing bugs in production code
Correct answer: Restructuring existing code without changing its external behavior to improve readability or reduce complexity
Refactoring improves code structure, readability, and maintainability without altering its observable behavior, reducing technical debt over time.
Question 5: What does CI/CD stand for in modern software development?
- Code Integration / Code Deployment
- Continuous Integration / Continuous Delivery (or Deployment) (Correct answer)
- Central Infrastructure / Containerized Deployment
- Change Implementation / Change Delivery
Correct answer: Continuous Integration / Continuous Delivery (or Deployment)
CI/CD stands for Continuous Integration (frequently merging code and running automated tests) and Continuous Delivery/Deployment (automatically preparing or releasing builds).
Question 6: What is the Observer design pattern used for?
- Creating a single instance of a class
- Defining a one-to-many dependency where changes in one object notify all its dependents automatically (Correct answer)
- Providing a surrogate for another object
- Composing objects into tree structures
Correct answer: Defining a one-to-many dependency where changes in one object notify all its dependents automatically
The Observer pattern establishes a subscription mechanism so that multiple observer objects are automatically notified when the subject they are watching changes state.
What is the purpose of unit testing?