Use the class definition below to answer the following questions.
public class TrafficLight { String stopLight = "red";
String waitLight;
String goLight;
public void setStopLight(String colour) { stopLight = colour; }
public String getGreenLight()
{ return goLight;
}
How many field attributes are there in the TrafficLight class?
Name a field attribute for this class.
What is the name of the method that is an accessor?
What is the name of the method that is a mutator?
What is the output type for the setStopLight method?
Write a Constructor for the TrafficLight class that sets stopLight value to “red”, waitLight to “yellow” and goLight to “green”?
How many field attributes are there in the TrafficLight class? Answer: 3 Name a field attribute for this class. Answer: stopLight What is the name of the method that is an accessor? Answer: getGreenLight What is the name of the method that is a mutator? Answer: setStopLight What is the output type for the setStopLight method Answer: void Write a Constructor for the TrafficLight class that sets stopLight value to “red”, waitLight to “yellow” and goLight to “green”? public TrafficLight() { stopLight = "red"; waitLight = "yellow"; goLight = "green"; }
Get Answers For Free
Most questions answered within 1 hours.