Prove that a number is even, given the cube is even
It sounds like you've more or less given a proof without realizing it. Proof by contrapositive
Yes it's a formal proof by contradiction and to be more accurate we write:
assume that $x$ is odd hence $x=2k+1$ for some $k$ and then $$x^3=(2k+1)^3=8k^3+12k^2+6k+1=2(\underbrace{4k^3+6k^2+3k}_{=k'})+1=2k'+1$$ so $x^3$ is odd which's a contradiction.
Your proof is correct: if $n$ was odd then $n^3$ would be odd as well, so $n$ must be even.