1) Firstly, let's locate to plot points A and B and the line y=x
Note that point to reflect over the line y=x, we need to follow this rule:
Pre-Image Rule Image
A(3,-1) (x,y) =(y,x) A'(-1,3)
B (3,1) (x,y) =(y,x) B'(1,3)
Notice that this reflection keeps the distance from line AB. Now let's plot the Image: