Question: LAB5: Object behaviors Question 5.1: Consider a Student class (without main method) with the following private instance variables: - first: a String variable for the

 LAB5: Object behaviors Question 5.1: Consider a Student class (without main

LAB5: Object behaviors Question 5.1: Consider a Student class (without main method) with the following private instance variables: - first: a String variable for the first name; - last: a String variable for the last name; - grade: a double variable for the grade. - studentNumber: an integer variable that is incremented when a student is created. 1. Add a constructor 1 that do nothing. 2. Add a constructor 2 that takes 3 parameters to initialize the instance variables. 3. Create a showStudent method that displays the information of one student (the instance variables). 4. Create a TestStudent class with main method in which: a. Create an object S1 with the first constructor. b. Create an object S2 with the second constructor. c. Call showStudent method for S1 and S2. d. Add the instruction S3=S2. Show the references of S1,S2 and S3. e. Call showstudent method for S3. Question 5.2: In the Student class, add: 1. getFirst: a method which returns the first name. 2. setFirst: a method that uses newFirst variable as parameter to initialize the first name. 3. getStudentNumber: a method which returns the student number. 4. In the main method, call the setFirst method for S1 and S2. 5. Show the first name of S1 and S2 using getFirst method. 6. Show the student number using getStudentNumber method

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 Databases Questions!