Step 1: Let the ages of A and B be \(4x\) and \(5x\) respectively, based on the given ratio.
Step 2: According to the problem, the sum of their ages is 72:
\[
4x + 5x = 72
\]
Step 3: Combine like terms:
\[
9x = 72
\]
Step 4: Solve for \(x\):
\[
x = \frac{72}{9} = 8
\]
Step 5: Calculate B's age by multiplying \(x\) by 5:
\[
5 \times 8 = 40
\]
Hence, B's age is 40 years.