Correct option is D
Let the number of boys in the class = 2x
Let the number of girls in the class = 3x
When three boys leave the class and three new girls the class the new ratio will be

14x – 21 = 9x + 9
5x = 30
x = 6
Girls in the class initially = 6 = 18