x - the number of questions he answered correctly
y - the number of questions he answered incorrectly
There were 40 questions on the test.

The correct answers were given 5 points each, the incorrect answers were given -2 points each. He made a score of 95.

Set 40-x and (-95/2)+(5/2)x equal to each other:

Johnny answered correctly
25 questions.