Exercises - Creating Java objects and methods
13. Exercises - Creating Java objects and methods 13.1. Create a Person class and instantiate it Create a new Java project called com.vogella.javastarter.exercises1 and a package with the same name. Create a class called Person . Add three instance variables to it, one for storing the first name of the person, one for storing the last name and one for storing the age of the Person. Use the constructor of the Person object to set the values to some default value. Add a toString method as described by the following coding and solve the TODO. This method is used to convert the object to a String representation. @Override public String toString () { // TODO replace "" with the following: // firstName + " " + lastName return "" ; } Create a new class called Main with a public static void main(String[] args) . In this method create an instance of the Person class. 13.2. Use constructor Add a construc...