Create a class called Student and define private instance variables id, firstName, lastName and age.
Create a default constructor and create an object called rajin and assign values of id = 1000, firstName as your first name, lastName = your last name and age = 25. Print the values of this object using toString() method. Make sure to override toString() method of Object class. The easy steps is: right click inside class outside main method and go to Source option and then generate toString option. Then click Generate.
Create static method called as getStudent that returns Student object. Create another student object and then set values to id = 1001, firstName = "John", lastName= "Doe" and age = 30. Call it in Main method to print those values.
--- old+++ new@@ -1,3 +1,3 @@1. Create a class called Student and define private instance variables id, firstName, lastName and age.
-2. Create a default constructor and create an object called rajin and assign values of id = 1000, firstName as "Rajin", lastName = "Panthee" and age = 25. Print the values of rajin object using toString() method. Make sure to override toString() method of Object class. The easy steps is: right click inside class outside main method and go to Source option and then generate toString option. Then click Generate.-3. Create static method called as getStudent that returns Student object. Create another student object named "sabin" and then set values to id = 1001, firstName = "sabin", lastName= "Basnet" and age = 30. Call it in Main method to print those values.+2. Create a default constructor and create an object called rajin and assign values of id = 1000, firstName as your first name, lastName = your last name and age = 25. Print the values of this object using toString() method. Make sure to override toString() method of Object class. The easy steps is: right click inside class outside main method and go to Source option and then generate toString option. Then click Generate.+3. Create static method called as getStudent that returns Student object. Create another student object and then set values to id = 1001, firstName = "John", lastName= "Doe" and age = 30. Call it in Main method to print those values.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Diff: