Question: 2 . Create a new java class, and name it Color 3 . Declare one data member of type String name it color . (
Create a new java class, and name it Color Declare one data member of type String name it color mark Define a method, name it setColor with one parameter String colorName and void return type. The implementation of this method is assigning colorName to color data member. mark Define a method, name it getColor with no parameter and String return type. The implementation of this method is to return color when the method is called. mark Inside the main method, create an object of class Color. mark Using the object you have created to call setColor, and pass any color you like to it mark Then, call getColor and print its value. mark
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
