Question: public class Student Inside the class, declare some data members: a String variable called studentMajor, a String variable firstName, a String variable lastName, an int
public class Student Inside the class, declare some data members: a String variable called studentMajor, a String variable firstName, a String variable lastName, an int called studentCredits, and an int called studentPoints /l declare some variables of different types: // a string called studentMajor /I an int called studentCredits // an int called studentPoints // a string called firstName // a string called lastName tep 3: Defining the constru Remember the constructor with arguments assigns input data to the data members. In this case, we have an example of constructors overloading. If user provides only First name and last name, then Constructor 1 is being called and rest of variables are initialized to default values, if user provides all variables, then java calls Constructor 2. Constructor 1: public Student (String fName, String iName) Il write the segment of code l/that assigns fName and Lname to variables Il The rest of variables are initialized to default values this.studentMajor "General Studies" this.studentPoints = 0; this.studentCredits 0; Constructor 2: public Student (String major, int credits, int points, String fName, String IName Il write the segment of code //that assigns input data to the data members
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
