The example of the defense mechanism "compensation" is:
You are failing math, so you decide to be the best basketball player on the team.
Compensation involves offsetting a perceived deficiency or failure in one area (in this case, math) by excelling in another area (basketball).