My task is to display the value variable grade for objects S1 and S2.
my code:
public class StudentTester{
public static void main(String[] args){
student S1 = new student();
student S2 = new student();
S1.setGrade(12);
System.out.println("Student one: " +S1+", Student two: "+S2);
}
public static 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;
}
}
}
When I print it get an an output like this:
Student one: StudentTester$student@ba4d54, Student two: StudentTester$student@12bc6874