It means to find the value of 'sum' after the for loops have been executed.
EDIT: The following assumes both of the last code pieces are inside the inner loop.
First we find the number of times sum+inc is executed. This is
$$\sum\limits_{i=1}^n\sum\limits_{j=1}^i1=\sum\limits_{i=1}^ni=\frac{n(n+1)}{2}.$$
Define $\mathrm{Inc}(k)$ as the value of inc in the $k$-th execution of sum+inc. Then
$$\mathrm{FinalSum}=\sum_{k=1}^{n(n+1)/2}\mathrm{Inc}(k)$$
For each time sum+inc is executed is executed, inc increases by $1$ and it starts at $0$, but we only increment inc after we have added it to sum, so $\mathrm{Inc}(k)=k-1$. Hence $$\begin{align}\mathrm{FinalSum}&=\sum_{k=1}^{n(n+1)/2}\mathrm{Inc}(k) \\\&=\sum_{k=1}^{n(n+1)/2}k-1 \\\&=\sum_{k=0}^{n(n+1)/2-1}k \\\&=\frac{(n(n+1)/2-1)(n(n+1)/2)}{2} \\\&=\frac{1}{8}\left(n(n+1)-2\right)\left(n(n+1)\right) \\\&=\frac{1}{8}n(n+1)(n^2+n-2) \end{align}$$