Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Create a class called Names that has two String type instance variables called firstName and lastName and one integer type class variable called count.

image text in transcribedJava
Create a class called Names that has two String type instance variables called firstName and lastName and one integer type class variable called count. The count variable should be used in the constructor in order to keep track of how many Names objects are instantiated. Make sure to include appropriate "get" and "set" methods. Create a class called OneName that has one String type instance variable called name. Create a method called public String swapName(Names name). This method accepts a Names object as an argument and swaps the value of firstName with the value of name in the OneName class. Make sure to include appropriate "get" and "set" methods. Create a class called TestName that contains the main method. Instantiate both a Names object and a OneName object. Set the values of the instance variables in both objects using user input. Output the values of the instance variables for both objects then use the swapName method and after that, output the values of the instance variables for both objects again

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 And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

More Books

Students also viewed these Databases questions

Question

2. What, according to Sergey, was strange at this meeting?

Answered: 1 week ago

Question

3. Are our bosses always right? If not, what should we do?

Answered: 1 week ago