Let the original number of students in the class be \(x\).
Their total age be \(40x\) (since the average age is 40 years).
When 12 new students with an average age of 32 years join, the total age of the new students is \(12 \times 32 = 384\).
The new average age of the class becomes \(40 - 4 = 36\).
The total number of students is now \(x + 12\), and their total age is \(40x + 384\).
The new average age is:
\(\frac{40x + 384}{x + 12} = 36\)
Multiplying both sides by \(x + 12\) we get,
\(\Rightarrow\;\)\(40x + 384 = 36(x + 12)\)
\(\Rightarrow\;\)\(40x + 384 = 36x + 432\)
\(\Rightarrow\;\)\(4x = 48\)
\(\Rightarrow\;\)\(x = \frac{48}{4} = 12\)
Therefore, the original strength of the class was 12 students.