CS FundamentalsVery hardProduct company interview · GATE level

In a class hierarchy, B, C and D extend A; E and F extend B; G extends E; H extends C. Using the Chidamber-Kemerer metrics with DIT(A) = 0, what is the largest depth of inheritance tree, what is NOC (number of children) of B, and how many classes are leaves?

  1. A. Max DIT 3; NOC(B) = 3; 4 leaves
  2. B. Max DIT 4; NOC(B) = 2; 4 leaves
  3. C. Max DIT 3; NOC(B) = 2; 4 leaves
  4. D. Max DIT 3; NOC(B) = 2; 3 leaves

Correct answer: C. Max DIT 3; NOC(B) = 2; 4 leaves

G's chain is G -> E -> B -> A, three edges, so DIT(G) = 3 is the maximum (counting classes instead of edges gives 4). NOC counts only immediate subclasses: B has E and F, so 2 - G is a grandchild and does not count. Leaves are classes with no subclasses: D, F, G and H.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic