Software Engineering Trivia 2 ā Questions and Answers
Question 1: Which sorting algorithm has the best average-case time complexity of O(n log n) and is commonly used in practice due to its in-place operation?
- Bubble Sort
- Merge Sort
- Quick Sort (Correct answer)
- Insertion Sort
Correct answer: Quick Sort
Quick Sort averages O(n log n) and sorts in-place, making it very cache-efficient and practical despite an O(n²) worst case.
Question 2: In object-oriented programming, what term describes a class that cannot be instantiated directly and is meant to be subclassed?
- Final class
- Abstract class (Correct answer)
- Static class
- Generic class
Correct answer: Abstract class
An abstract class defines a template with some unimplemented methods that subclasses must provide, preventing direct instantiation.
Question 3: What does REST stand for in the context of web API design?
- Remote Execution State Transfer
- Representational State Transfer (Correct answer)
- Resource Entity Sharing Template
- Relational Entity State Transmission
Correct answer: Representational State Transfer
REST (Representational State Transfer) is an architectural style for distributed hypermedia systems, coined by Roy Fielding in 2000.
Question 4: Which data structure uses LIFO (Last In, First Out) order for element access?
- Queue
- Deque
- Stack (Correct answer)
- Priority Queue
Correct answer: Stack
A stack follows LIFO ordering, where the most recently pushed element is the first to be popped.
Question 5: In version control with Git, what command creates a new branch and immediately switches to it?
- git branch new-branch
- git switch new-branch
- git checkout -b new-branch (Correct answer)
- git create -b new-branch
Correct answer: git checkout -b new-branch
`git checkout -b <branch>` is the classic command that creates and checks out a new branch in a single step.
Question 6: What is the term for a software defect introduced when fixing another bug, often caused by insufficient test coverage?
- Regression (Correct answer)
- Mutation
- Degradation
- Cascade failure
Correct answer: Regression
A regression is a bug that reappears or a new bug introduced by a change, typically caught by regression testing suites.
Question 7: Which principle in SOLID design states that a class should have only one reason to change?
- Open/Closed Principle
- Liskov Substitution Principle
- Single Responsibility Principle (Correct answer)
- Interface Segregation Principle
Correct answer: Single Responsibility Principle
The Single Responsibility Principle (SRP) states each class should encapsulate only one aspect of functionality, reducing coupling.
Which sorting algorithm has the best average-case time complexity of O(n log n) and is commonly used in practice due to its in-place operation?