Question
5. Write the statement that would assign your name to the memory location declared above. _____________________________________________________________________________ 6. What was the name of the method in
5. Write the statement that would assign your name to the memory location declared above. _____________________________________________________________________________ 6. What was the name of the method in the Ball class that displayed information about the ball? _ _____________________________________________________________________________ 7. Write the Java command that would display the current owner of the credit card object - whomever it was at any time. (Writing the method is not necessary here just the display statement.) It might look like this with the blank filled with the current owners name: _____________________________________________________________________________ 8. Explain the difference between an accessor and a mutator method. Give an example of each from the Student class (lab-classes project). _________________________________________ _____________________________________________________________________________
code
/** * Write a description of class ball here. * * @author (your name) * @version (a version number or a date) */ public class ball { // instance variables - replace the example below with your own private String color; private int diameter;
/** * Constructor for objects of class ball */ public ball() { // initialise instance variables color = "red"; diameter = 10; }
/** * An example of a method - replace this comment with your own * * @param y a sample parameter for a method * @return the sum of x and y */ public String getColor(){ return color; } public int getDiameter(){ return diameter; } public void setYellowColor(){ color = "yellow"; } public void setOrangeColor(){ color = "orange"; } public void setBallColor(String setColor){ color = "setColor"; } }
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