ME or MEng Master of Engineering Master of Software Engineering 3 — Questions and Answers
Question 1: In the context of distributed systems, what does the CAP theorem state?
- A system can guarantee Consistency, Availability, and Partition tolerance simultaneously
- A distributed system can provide at most two of: Consistency, Availability, and Partition tolerance (Correct answer)
- Consistency and Availability are always achievable if network partitions are rare
- Partition tolerance can be sacrificed to achieve both Consistency and Availability
Correct answer: A distributed system can provide at most two of: Consistency, Availability, and Partition tolerance
CAP theorem proves that when a network partition occurs, a distributed system must choose between consistency and availability.
Question 2: Which design pattern ensures a class has only one instance and provides a global point of access to it?
- Factory Method
- Prototype
- Singleton (Correct answer)
- Flyweight
Correct answer: Singleton
The Singleton pattern restricts instantiation of a class to a single object and provides a static accessor for that instance.
Question 3: What is 'technical debt' in software engineering?
- The financial cost of software licenses accumulated over time
- The implied cost of future rework caused by choosing an expedient but suboptimal solution now (Correct answer)
- The number of open bug reports in a system's backlog
- The overhead of maintaining legacy APIs for backward compatibility
Correct answer: The implied cost of future rework caused by choosing an expedient but suboptimal solution now
Technical debt describes the long-term maintenance burden incurred when shortcuts or poor design decisions are made to meet short-term goals.
Question 4: In OAuth 2.0, what is the role of the 'authorization code' flow's PKCE extension?
- To encrypt the access token during transmission
- To prevent authorization code interception attacks in public clients (Correct answer)
- To allow refresh tokens to be used without client secrets
- To enable multi-factor authentication for native apps
Correct answer: To prevent authorization code interception attacks in public clients
PKCE (Proof Key for Code Exchange) uses a code verifier/challenge pair to prevent an intercepted authorization code from being exchanged by a malicious actor.
Question 5: Which software process model is most appropriate when requirements are well-understood, stable, and the project has a fixed scope?
- Scrum
- Extreme Programming (XP)
- Waterfall (Correct answer)
- Kanban
Correct answer: Waterfall
Waterfall suits projects with stable, well-defined requirements where each sequential phase (requirements → design → implementation → testing) can be completed before the next.
Question 6: What is the purpose of an Abstract Syntax Tree (AST) in a compiler or interpreter?
- To store the symbol table mapping variables to memory addresses
- To represent the hierarchical syntactic structure of source code for analysis and transformation (Correct answer)
- To encode bytecode instructions for a virtual machine
- To track which lines of code have been executed during profiling
Correct answer: To represent the hierarchical syntactic structure of source code for analysis and transformation
An AST is a tree-shaped intermediate representation of source code's syntactic structure, used for semantic analysis, optimization, and code generation.
Question 7: In formal software verification, what does 'Hoare logic' provide?
- A probabilistic model for estimating defect rates
- A proof system using preconditions and postconditions to reason about program correctness (Correct answer)
- A static type system for preventing null pointer exceptions
- A runtime monitoring framework for safety-critical systems
Correct answer: A proof system using preconditions and postconditions to reason about program correctness
Hoare logic uses triples {P} C {Q} — precondition P, command C, postcondition Q — to formally prove that a program segment behaves correctly.
In the context of distributed systems, what does the CAP theorem state?