Question: 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.

 Java Create a class called Names that has two String typeJava

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

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!