CS FundamentalsVery hardGATE CS · Product placement
A module handleIO(kind, data) contains one big switch: kind 1 reads from the keyboard, kind 2 writes a file, kind 3 sends a network packet. Callers pass kind to choose. Which cohesion does the module have, and which coupling do its callers have with it?
- A. Functional cohesion and data coupling
- B. Temporal cohesion and stamp coupling
- C. Communicational cohesion and common coupling
- D. Logical cohesion and control coupling
Correct answer: D. Logical cohesion and control coupling
The operations are grouped only because they are logically similar ('all I/O'), not because they work together: logical cohesion. Callers steer its internal logic with a flag, which is control coupling. Splitting it into three functions fixes both.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- For integer variables, what is the weakest precondition wp(x := x + 1; y := 2 x, y > 10)?
- Which Hoare triple is valid for integer variables (partial correctness)?
- This loop sums an array: python i = 0; s = 0 while i < n: s = s + a[i] i = i + 1 Which assertion is a loop invariant (true every time the…
- Two identical servers run in parallel (the system works while at least one does). Each fails independently with an exponential failure…
- A team fits the Goel–Okumoto reliability-growth model μ(t) = a(1 − e^(−bt)) to its test data, with a = 120 expected total faults and b =…
- Why does the classic hardware 'bathtub' failure curve not fit software?