For solving this type of problem, we need to have good knowledge of Addition Theorem of Probability. According to addition theorem, if we have two Mutually Exclusive Events then we can find the Union of the entire event by the formula given below:
P (A ∪B) = P (A) +P (B) - P (A∩B)
If we talk about our question we have number of Students who like Math so probability will be P(A) = 30 and the number of students who like Science are 40 so P(B) = 40 and the number of students who like both math and science are 12 so P(A∩B) = 12 , our task is to find the number of students in the class that we can find by finding P(A ∪B), so by the additional formula,
P (A ∪B) = 40 + 30 – 12
P (A ∪B) = 58
So the total number of student in the class is 58.