Step 1: Identify the total downward displacement.
The ball first falls \(2\,m\) before touching the spring, and then compresses the spring by \(50\,cm = 0.5\,m\).
\[
s = 2 + 0.5 = 2.5\,m
\]
Step 2: Work done by gravity.
\[
W_g = mgs
\]
Taking \(g = 10\,ms^{-2}\),
\[
W_g = 0.5 \times 10 \times 2.5
\]
\[
W_g = 12.5\,J
\]
Step 3: Work done against spring force.
Energy stored in compressed spring is:
\[
W_s = \frac{1}{2}kx^2
\]
\[
W_s = \frac{1}{2} \times 24 \times (0.5)^2
\]
Step 4: Calculate spring work.
\[
W_s = 12 \times 0.25
\]
\[
W_s = 3\,J
\]
Step 5: Net work done.
Net work done on the ball is work done by gravity minus work stored in spring.
\[
W_{\text{net}} = W_g - W_s
\]
\[
W_{\text{net}} = 12.5 - 3
\]
Step 6: Final conclusion.
\[
W_{\text{net}} = 9.5\,J
\]
\[
\boxed{9.5\,J}
\]
Hence, correct answer is option (D).