Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions