IntelliJ Java IDE
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes implements a listener Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "implements a listener" Watch "implements a listener" New topic
Author

implements a listener

tony wang
Greenhorn

Joined: Apr 13, 2002
Posts: 14
Question #12:
Given that you have a class that implements HttpSessionAttributeListener with only the following methods:
public void attributeAdded(HttpSessionBindingEvent se){
//do something here}
public void attributeRemoved(HttpSessionBindingEvent se){
//do something here}
What is the result of compiling/executing this code?
A Compiles but will not do anything
B Code would work if HttpSessionBindingListener was implemented
C Code would only work in a Tag class
D Code will not compile
The answer is D ->Error takes place as method: attributeReplaced(HttpSessionBindingEvent se) is not defined.
But I still can't figure out why. Just because the class implements a listener interface


SCJP,SCWCD
tony wang
Greenhorn

Joined: Apr 13, 2002
Posts: 14
aw, right. HttpSessionAttributeListener is an abstract interface
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
aw, right. HttpSessionAttributeListener is an abstract interface
What is an abstract interface......
- madhav


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
HttpSessionAttributeListener is an interface. So u have to implement all its methods. There are 3 methods and only 2 are implemented ..so will not compile
 
 
subject: implements a listener
 
Threads others viewed
Don't understand Final Mock Exam #22, 55
HttpSessionAttributeListener
doubt on HttpSessionBindingListener
Difference b/w HttpSessionAttributesListener and HttpSessionBindingListener
Doubt in Listener?
developer file tools