Use the class definition below to answer the following questions. [Total 8 Marks] public class TrafficLight { String...

50.1K

Verified Solution

Question

Programming

Use the class definition below to answer the followingquestions. [Total 8 Marks]

public class TrafficLight {

String stopLight = \"red\";

String waitLight;

String goLight;

public void setStopLight(String colour) {

stopLight = colour; }

public String getGreenLight() {

return goLight; } }

1 :How many field attributes are there in the TrafficLightclass?

2 :Name a field attribute for this class.

3 :What is the name of the method that is an accessor?

4 :What is the name of the method that is a mutator?

5 :What is the output type for the setStopLightmethod ?

6 :Write a Constructor for the TrafficLight class that setsstopLight value to “red”, waitLight to “yellow” and goLight to“green”?

Answer & Explanation Solved by verified expert
3.9 Ratings (753 Votes)
Ques 1 There are 3 attributes in the TrafficLight class Explanation First one is stopLight Second one is waitLight and Third one is goLight Ques 2 One field attribute is goLight Explanation There are    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students