• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

implements a listener

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
tony wang
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aw, right. HttpSessionAttributeListener is an abstract interface
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aw, right. HttpSessionAttributeListener is an abstract interface
What is an abstract interface......
- madhav
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I've been selected to go to the moon! All thanks to this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic