Let the present age of A be $4x$ years and the present age of B be $5x$ years.
Then, the ratio of their present ages is:
\[
\frac{4x}{5x} = \frac{4}{5}
\]
After 6 years:
- Age of A = $4x + 6$
- Age of B = $5x + 6$
Given that the ratio of their ages after 6 years is $5:6$:
\[
\frac{4x + 6}{5x + 6} = \frac{5}{6}
\]
Cross-multiplying:
\[
6(4x + 6) = 5(5x + 6)
\]
\[
24x + 36 = 25x + 30
\]
\[
36 - 30 = 25x - 24x \Rightarrow 6 = x
\]
Now compute their present ages:
\[
\text{A's age} = 4x = 4 \times 6 = 24 \text{ years}
\]
\[
\text{B's age} = 5x = 5 \times 6 = 30 \text{ years}
\]
Check:
After 6 years:
\[
\text{A's age} = 24 + 6 = 30,\quad \text{B's age} = 30 + 6 = 36
\]
\[
\text{Ratio} = \frac{30}{36} = \frac{5}{6} \quad \text{✓ Matches given condition}
\]
Final Answer:
\[
\boxed{24 \text{ years}}
\]