Question: Write a program that tests the Person class defined in the following. Place this test program in a separate file called TestPerson.java and make sure

Write a program that tests the Person class defined in the following. Place this test program in a separate file called TestPerson.java and make sure you can call the constructor and the methods of the Person class correctly. That is, your test program should create a Person object using the no-arg constructor (default one), print out the default name, assign a name such as John Doe and display the name via invoking a method on a Person object.

public class Person {

private String name;

public Person( ) {

name = "Unknown";

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

}

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!