CS FundamentalsVery hardProduct-company placement

A class has fields a, b, c, d and methods m1 (uses a, b), m2 (uses b), m3 (uses c), m4 (uses c, d) and m5 (uses no field but calls m1). Using LCOM4 (methods are linked if they share a field or one calls the other; LCOM4 = number of connected groups), what is its value and what does it suggest?

  1. A. 1; the class is cohesive
  2. B. 3; split it into three classes
  3. C. 5; every method stands alone
  4. D. 2; the class could be split in two

Correct answer: D. 2; the class could be split in two

m1–m2 share b and m5 calls m1, giving {m1, m2, m5}; m3–m4 share c, giving {m3, m4}. Two components mean two unrelated responsibilities. Ignoring the call edge would wrongly make m5 a third group.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic