Let the number of boys in the class be \(b\).
According to the question,
\(\frac 23 b = 18\)
\(b = 24\)
Let the total number of students in the class be \(t\).
According to the question,
\(\frac 23t = 24\)
\(t = 36\)
Total number of students in class \(= 36\)
Number of girls in the class \(= 36 - 24 = 12\)
So, the correct option is (B) : 12.