Question: Write a class called Person class. The Person class contains Two instance variable named name (of type String) and age (of type int) . A

 Write a class called Person class. The Person class contains Two

Write a class called Person class. The Person class contains Two instance variable named name (of type String) and age (of type int) . A constructor that creates a Person instance with the given parameters. It must assign age after confirming the argument passed is not negative; if a negative argument is passed, the constructor should set age to 0 . Getters and setters for instance variables name and age . A toString() that returns a short description of the instance. A yearPasses() method that increases the age by 1 Write the Person class in the answer box below. Note - keep a copy of your solution to this task because you will be extending it step by step in subsequent tasks For example Test Result Person p- new Person(Joe 12)Joe (12) System.out.println(p)

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!