Software Engineering Basic Software Engineering 5 — Questions and Answers
Question 1: What is the main advantage of Test-Driven Development (TDD)?
- It eliminates the need for integration tests
- It ensures tests are written before code, clarifying requirements and catching regressions early (Correct answer)
- It allows developers to skip code reviews
- It automatically generates documentation from test cases
Correct answer: It ensures tests are written before code, clarifying requirements and catching regressions early
TDD's red-green-refactor cycle forces developers to define expected behavior before implementation, leading to better-designed, well-tested code.
Question 2: What is the difference between a process and a thread in software execution?
- Processes and threads are identical concepts with different names
- A process is an independent program with its own memory; a thread is a lightweight unit of execution within a process sharing its memory (Correct answer)
- A thread is slower than a process because it runs on a single core
- Processes are used in web apps; threads are used only in operating systems
Correct answer: A process is an independent program with its own memory; a thread is a lightweight unit of execution within a process sharing its memory
Processes have separate memory spaces and resources, while threads within the same process share memory, making threads lighter but requiring synchronization.
Question 3: In software engineering, what does 'cohesion' refer to?
- The degree to which components in a system depend on each other
- The degree to which elements within a single module are functionally related (Correct answer)
- The ability of a system to recover from failures
- The consistency of the user interface across screens
Correct answer: The degree to which elements within a single module are functionally related
High cohesion means that a module's responsibilities are strongly related and focused, making it easier to understand and maintain.
Question 4: What is a 'deadlock' in concurrent programming?
- A situation where a thread runs indefinitely without producing output
- A state where two or more threads are each waiting for resources held by the other, preventing any from proceeding (Correct answer)
- A memory leak caused by circular object references
- An exception thrown when a thread accesses a null pointer
Correct answer: A state where two or more threads are each waiting for resources held by the other, preventing any from proceeding
Deadlock occurs when processes are stuck in a circular wait, each holding a resource the other needs, so none can make progress.
Question 5: What is the purpose of an abstract class in object-oriented programming?
- To create objects that cannot hold any data
- To define a common interface and partial implementation that subclasses must complete (Correct answer)
- To prevent any other class from inheriting its properties
- To store only static methods and constants
Correct answer: To define a common interface and partial implementation that subclasses must complete
An abstract class provides a template with some implemented behavior and declares abstract methods that concrete subclasses are required to implement.
Question 6: Which HTTP method is conventionally used to update an existing resource in a RESTful API?
- GET
- POST
- PUT (Correct answer)
- DELETE
Correct answer: PUT
PUT replaces an existing resource at a specified URI with the provided representation, making it the standard for full updates in REST.
Question 7: What does 'scalability' mean in the context of software systems?
- The ability of a system to handle increased load by adding resources without redesigning the system (Correct answer)
- The process of reducing a codebase's size through refactoring
- The compatibility of software with multiple operating systems
- The ease with which new developers can learn a codebase
Correct answer: The ability of a system to handle increased load by adding resources without redesigning the system
A scalable system can accommodate growing demand — whether through vertical scaling (more powerful hardware) or horizontal scaling (more instances).
What is the main advantage of Test-Driven Development (TDD)?