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

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