The variance is the sum of the squared deviations from the expected value weighted by the probability of each outcome.
The expected value is E(X) = 0.3 × 2 + 0.4 × 3 + 0.3 × 4 = 3.
The variance is 0.3 × (2 − 3)2 + 0.4 × (3 − 3)2 + 0.3 × (4 − 3)2 = 0.6.