Exercises
Now that you understand an object's life cycle, it is time to spend some time in JShell creating new classes and instances.
Exercise 1
Create a new
Studentclass with a constructor that requires twoStringarguments:firstNameandlastName. Use the arguments to initialize fields with the same names as the arguments. Display a message with the values forfirstNameandlastNamewhen an instance of the class is created.Create an instance of the
Studentclass and assign it to a variable. Check the messages printed in JShell.Create an instance of the
Studentclass and assign it to a variable. Check the messages printed in JShell.
Exercise 2
Create a function that receives two
Stringarguments:firstNameandlastName. Create an instance of the previously definedStudentclass with the received arguments as parameters for the creation of the instance. Use the instance properties to print a message with the first name followed by a space and the last name. You will be able to create a method...