4. As shown in Figure 1, the diagonals $AC$ and $BD$ of quadrilateral $ABCD$ are perpendicular to each other. If $AB=3, BC$ $=4, CD=5$, then the length of $AD$ is ( ).
(A) $3 \sqrt{2}$
(B) 4
(C) $2 \sqrt{3}$
(D) $4 \sqrt{2}$
4.A.

As shown in Figure 6, let the four segments into which the diagonals $AC$ and $BD$ of quadrilateral $ABCD$ are divided be $a, b, c, d$. By the Pythagorean theorem, we have
$$
a^{2}+b^{2}=3^{2}, b^{2}+c^{2}=4^{2}, c^{2}+d^{2}=5^{2} \text {. }
$$

Then $a^{2}+d^{2}=18=AD^{2}$. Therefore, $AD=3 \sqrt{2}$.