For potential flow, the stream function \( \psi \) and velocity potential \( \phi \) are related through the equations:
\[
u = \frac{\partial \phi}{\partial x}, \quad v = \frac{\partial \phi}{\partial y}
\]
and the stream function \( \psi \) is related to the velocity components by:
\[
u = \frac{\partial \psi}{\partial y}, \quad v = -\frac{\partial \psi}{\partial x}
\]
The stream function is given as \( \psi = xy^2 \). Now, differentiate \( \psi \) with respect to \( y \) and \( x \):
\[
u = \frac{\partial \psi}{\partial y} = 2xy
\]
\[
v = -\frac{\partial \psi}{\partial x} = -y^2
\]
Now, we integrate \( u = 2xy \) with respect to \( x \) to find \( \phi \):
\[
\phi = \int 2xy \, dx = x^2y + f(y)
\]
Next, differentiate \( \phi = x^2y + f(y) \) with respect to \( y \) and equate it to \( v = -y^2 \):
\[
\frac{\partial \phi}{\partial y} = x^2 - f'(y) = -y^2
\]
Solving for \( f'(y) \), we get:
\[
f'(y) = x^2 + y^2
\]
Thus, the velocity potential \( \phi \) is:
\[
\phi = y \left( x^2 - \frac{y^2}{3} \right)
\]
Thus, the correct answer is (D).