My task is : Call the ‘setGrade’method to assign to the grade variable of S1 the value of 11
the code is:
public class student {
private String name;
private int age;
private int grade;
private double average;
private boolean disability;
private void printStudentInfo(){
//Data Encapsulation is methods of the public interface provide access to private data, while hiding implementation.
System.out.println("Name: "+name+",Age: "+age+",Grade: "+grade+",Average: "+average +" Disability: "+disability);
}
public void setGrade(int newGrade){
grade=newGrade;
}
public int getGrade(){
return grade;
}
//this part was given from the question
//from here
public class StudentTester{
public static void main(String[] args){
student S1 = new student();
student S2 = new student();
//to here
S1.setGrade(12);
}
}
}
Every time I run my program it gives me an error
modifier 'static' is only allowed in constant variable declarations