Question: What value is output if the program TestStudent is executed given the following definition for TestStudent and Student? public class Student { private double GPA;

What value is output if the program TestStudent is executed given the following definition for TestStudent and Student?
public class Student {
private double GPA;
private int credits;
public Student(){
this.GPA =0.0;
this.credits =0;
}
public void increaseCredits(int amount){
this.credits = this.credits + amount;
}
public void setCredits(int credits){
this.credits = credits;
}
public int getCredits(){
return credits;
}
}
public class TestStudent {
public static void main(String [] args){
Student s = new Student();
Student t = new Student();
s.setCredits(8);
s.increaseCredits(3);
t.increaseCredits(2);
System.out.println(s.getCredits());
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!