Let [tex]a_1,\ldots,a_4[/tex] denote the ages of the 4 candidates. Then
[tex]\dfrac{a_1+a_2+a_3+a_4}4=40[/tex]
[tex]a_1+a_2+a_3+a_4=160[/tex]
[tex]\dfrac{a_1+a_2+a_3}3+\dfrac{a_4}3=\dfrac{160}3[/tex]
The average age of the first 3 candidates is 42, so
[tex]\dfrac{a_4}3=\dfrac{160}3-42[/tex]
[tex]\implies\boxed{a_4=160-3\cdot42=34}[/tex]