Question: Compile and execute the code in java: Student.java public class Student { / / a class named Student private String firstName; / / See Teacher
Compile and execute the code in java:
Student.java
public class Student a class named Student
private String firstName; See Teacher class for reference
private String lastName; See Teacher class for reference
private double gpa; an instance variable of type double to keep track of student GPA
private int numCreditsGained; an instance variable of type int to keep
track of the number of credits gained by this student
Student constructor
public StudentString firstName, String lastName, double gpa, int numCreditsGained
this.setFirstNamefirstName; Example of using a setter method to set the instance variables
this.setLastNamelastName; See Teacher constructor for an alternate way of
assignment instance variables
this.setGpagpa;
this.setNumCreditsGainednumCreditsGained;
public String getFirstName Getter method
return firstName;
public void setFirstNameString firstName Setter method
this.firstName firstName;
public String getLastName
return lastName;
public void setLastNameString lastName
this.lastName lastName;
public double getGpa
return gpa;
public void setGpadouble gpa
this.gpa gpa;
public int getNumCreditsGained
return numCreditsGained;
public void setNumCreditsGainedint numCreditsGained
this.numCreditsGained numCreditsGained;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
