Question: In Java Create a class called Person with the following features: a. It has a private data member (instance variable) called name of type String.

In Java Create a class called

Person

with the following features:

a.

It has a private data member (instance variable) called name of type String.

b.

It has three constructors, a no-

argument constructor, a one parameter

constructor, and a copy constructor. The no-

argument constructor sets name to

an empty string . The one parameter constructor sets name to the value of

the argument. The copy constructor has a parameter of type Person and it

creates a new object which is an exact copy of its argument.

c.

It has an accessor method (getName) which returns the persons name and a

mutator method (setName) which sets the persons name to the value of its

argument.

d.

It has a toString method that returns the persons name(Name = name)

.

e.

It has an equals method that returns true if two

Persons have identical names.

Thank you for any help.

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!