Let the ages of A and B before 7 yr were 3k yr and 4k yr, respectively.
∴ Present age of A = 3k + 7
and present age of B = 4k + 7
Now, according to the question,
∴ (3k + 7 + 9) / (4k + 7 + 9) = 7/8
⇒ 24k + 128 = 28k + 112
⇒ 4k = 16
∴ k = 4
Hence, present age of B = 4 x 4 + 7
= 16 + 7 = 23 yr