I don't know where grade1 or grade2 comes from, as we are only seeing one function, so I assume that those two variables are other variables in the class.
public void setQuiz(int quiz, int grade)
{
if (quiz == 1)
grade1 = grade;
else if (quiz == 2)
grade2 = grade;
}