diagonalize A, then look at the action of B on each of the eigenspaces of A (which is closed because [A,B]=0) and diagonalize B on each individual eigenspace of A, and you're done
@EmilioPisanty Can do. Do you have a reason to believe it's not on-topic at CS though? (We're not really supposed to bother mods unless whether or not the question is in-scope is unclear. If we possibly wouldn't migrate it for quality reasons, just don't migrate)
and you find two eigenspaces, one spanned by $e_1=(1,1,0,0)$ and $e_2=(0,0,1,1)$ with eigenvalue $+1$, and one spanned by $e_3=(1,-1,0,0)$ and $e_4=(0,0,1,-1)$ with eigenvalue $-1$.
Then you find the action of $B$ on those eigenspaces
so $Be_1=e_2$ and $Be_2=e_1$, and ditto with $Be_3=e_4$ and $Be_4=e_3$,
:40354732 That message was causing strange layout artifacts on my machine, so I have deleted it for the nonce. If this was unique to me I can restore it, but it seemed to be a problem.
@Phase the non-degenerate case is a strict special case of the degenerate case and it does not require additional attention once you're doing the general situation
more specifically, if a given eigenvalue of A is nondegenerate then you'll get a 1x1 block in the B matrix over that eigenbasis, which you then proceed to diagonalize (by doing nothing)
You need to know (0a) enough classical mechanics to know what a Lagrangian is and how to use it; (0b) enough electricity and magnetism to be able to write the energy in an electromagnetic wave; (1) some quantum mechanics; (2) the ladder-operator solution to the harmonic oscillator in quantum mechanics; (3) probably a few other things, but you can pick them up as you need them.
there is at least one fact you can infer from the diagonal elements being zero: the trace of the matrix is zero, so the sum of the eigenvalues is zero.
take $\tilde B =[B]_{A\text{ eigenbasis}}=V^{-1}BV=\begin{pmatrix}0&1&0&0\\ 1& 0&0&0 \\0&0&0&1 \\ 0&0&1&0\end{pmatrix}$ as above and say that you want to diagonalize it. You might say "hey, $(1,1,0,0)$ looks like a handy eigenvector. Or you might say "hey $(1,1,1,1)$ looks like a handy eigenvector".
and similarly the determinant is 1, so the product of the eigenvalues is 1. that sets some pretty strong constraints on it. that'd allow eigenvalues like 1,1,-1,-1; but, it'd also allow 2,-2, 1/2, -1/2. (that doesn't happen here, but the facts i've quoted aren't enough to prevent that)
keeping in mind that in that basis $\tilde A =[A]_{A\text{ eigenbasis}}=V^{-1}AV=\begin{pmatrix}1&0&0&0\\ 0& 1&0&0 \\0&0&-1&0 \\ 0&0&0&-1\end{pmatrix}$
$(1,1,0,0)$ stays inside the upper 2x2 block and it is therefore guaranteed to be an eigenvector of $A$. $(1,1,1,1)$ breaks out of that block and it is therefore not an eigenvector of $A$.
this is why it is crucial that you diagonalize $B$, on the $A$ eigenbasis, on a block-by-block (i.e. eigenspace by eigenspace) basis
so because in a twofold degenerate eigenspace, any two orthogonal vectors in it are eigenvectors right? So you can break it into two 2x2 matrices each representing the eigenspace?