Question
Java programming questions- 1- In the java.awt.event package, there is an ActionListener interface that many classes implement when they want to be made aware of
Java programming questions-
1- In the java.awt.event package, there is an ActionListener interface that many classes implement when they want to be made aware of events that occur, such as mouse clicks on buttons. (a) Why is ActionListener an interface instead of an abstract class?
(b) How would making ActionListener an abstract class decrease the usability of the class?
2- For each of the following pairs of classes, tell which class of the pair should be a subclass of which, if either. Briefly explain why or why not. Please actually think about this. Remember our discussion of is-a versus has-a.
(a) Car and Tire
(b) Car and Truck
(c) Card (with suit and value instance variables) and Deck (of 52 cards)
3-Determine the proper relationship between the following classes. That means which ones should be subclasses of others and which should be composed of others? You may add extra classes or interfaces (for example, a common superclass or interface of two of the classes) if you feel they will help clarify the relationship. Explain your reasoning. Boat, BoatHouse, House, HouseBoat, Garage, Car
Please explain briefly with examples
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