My original pdf is $f(y) = \frac{n (y_{n} - \theta_{1})^{n-1}}{(\theta_{2} - \theta_{1})^{n}}$ for $\theta_{1} < y < \theta_{2}$.
After using U-substitution, I obtain $E(Y) = \frac{n \theta_{2} + \theta_{1}}{(n+1)}$.
For variance of $Y$, I need to find $E(Y^2)$ first.
This is what I have with U-substitution: $E(Y^2) = \frac{n\theta_{2} - n \theta_{1} + 2n \theta_{1} \theta_{2} - n\theta_{1}^{2} + \theta_{1}^{2}}{(n+1)}$.
But with this the $Var(Y)= E(Y^2) - \left [E(Y) \right ]^{2} \neq n\frac{(\theta _{1} - \theta _{2})^{2}}{(n+1)^{2} (n+2)}$
My mistake is definitely the $E(Y^2)$ part, so I would appreciate it if someone here can go over it with me.
Edit: $$\begin{eqnarray} \mathbb{E}\left(Y^2\right) &=& \mathbb{E}\left(\left(Y-\theta_1\right)^2\right) + 2 \theta_1 \cdot \mathbb{E}\left(\left(Y-\theta_1\right)\right) + \theta_1^2 \\ &=& \frac{n}{n+2} \left(\theta_2-\theta_1\right)^2 + 2 \theta_1 \cdot \frac{n}{n+1} \left(\theta_2-\theta_1\right) + \theta_1^2 \end{eqnarray}$$ from below and also my own work.
But now how do I simplify $$Var(Y) = \mathbb{E}\left(Y^2\right) - \left [ \mathbb{E}\left(Y\right) \right ]^{2}$$ to $$Var(Y) = n\frac{(\theta _{1} - \theta _{2})^{2}}{(n+1)^{2} (n+2)}?$$
Instead of $\theta_1$ and $\theta_2$ I will use $a$ and $b$.
For the expectation of $Y^2$, we want $$\int_a^b \frac{ny^2(y-a)^{n-1}}{(b-a)^n}\,dy.$$ If we let $u=y-a$, then $y^2=u^2+2au+a^2$. So we want $$\frac{n}{(b-a)^n}\int_{u=0}^{b-a} \left(u^{n+1}+2au^{n}+a^2u^{n-1}\right)\,du.$$ This is, after minor simplification, equal to $$\frac{n}{n+2}(b-a)^{2}+\frac{2an}{n+1}(b-a)+a^2.$$
A similar but simpler calculation shows that $E(Y)=\frac{n}{n+1}(b-a)+a$.
The calculation of $E(Y^2)-(E(Y))^2$ is simple, since there is some nice cancellation. We get $$(b-a)^2\left(\frac{n}{n+2}-\frac{n^2}{(n+1)^2}\right),$$ which simplifies to $$(b-a)^2\frac{n}{(n+2)(n+1)^2}.$$