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
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