Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started