5) The partial Student class shown below is used in this problem: public class S
ID: 3558912 • Letter: 5
Question
5) The partial Student class shown below is used in this problem: public class Student { private int score ; public Student(String newName, int newScore) {. . . } public int getScore() { . . . } public void setScore(int newScore) { . . . } } Implement the method specified below. For full credit your code should not create any more objects than necessary. Maximum score assigned can't exceed 100. (10 Pts.) // Method addBonus adds bonusPoints points to the scores of all students in the given classList. public static void addBonus(Student[] classList, int bonusPoints) {Explanation / Answer
public static void addbonus(student[]classList,int bonusPoints)
{
score=score+bonusPoints;
if(score>=100)
{
score=100;
}
}
/*The point to be noted here is that the method addBonus is inside the class student.And Also Since score is private it can only be accesssed inside the class Student
i.e by its methods only.Even if an Object is created of class Student that object can not access the variable score.Since its private.*/