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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started