Computer Science, asked by harshini7929, 1 year ago

Difference between adapter class and listeners

Answers

Answered by writersparadise
24

In an adapter class, there is no need for implementation of all the methods presented in an interface. It is used when only some methods of defined by its interface have to be overridden.


In a listener, all the methods that have been declared in its interface have to be implemented. This is because these methods are final.
Answered by Shaizakincsem
7
Listeners are used when you plan to utilize most of the interface methods. When you need to use only a few of the methods an adapter would be better b/c you would not have to override the remainder of the methods.

WindowListener is interfaced which force you to override all of the methods, while WindowAdapter is the implementation of WindowListener and you only need to override the method(s) that you interest to deal with.
Similar questions