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?

  1. A. Functional cohesion and data coupling
  2. B. Temporal cohesion and stamp coupling
  3. C. Communicational cohesion and common coupling
  4. 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.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic