Question: 2 . Create a new java class, and name it Color 3 . Declare one data member of type String name it color . (

2. Create a new java class, and name it Color 3. Declare one data member of type String name it color.(0.25 mark)4. 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. (0.5 mark)5. 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. (0.5 mark)6. Inside the main method, create an object of class Color. (0.5 mark)7. Using the object you have created to call setColor, and pass any color you like to it.(0.5 mark)8. Then, call getColor and print its value. (0.25 mark)

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 Programming Questions!