This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpSessionBindingListener

 
Purusottam Mohanty
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An object X implement's a HttpSessionBindingListener.
The valueBound method is to print "B" and the valueUnbound method is to
print "U".

The code to be executed is :

session.setAttribute("A", new X());
session.setAttribute("A", new X());
session.removeAttribute("A");

What should be output:

1.BBU 2.BUBU or 3.BBUU

and why ?

all responses are appreciated.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would your answer be. And why?
 
Purusottam Mohanty
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would prefer to go for BUBU as it seems more logical.
The first instance is bound to the sesssion for key "A" : 'B'
To bound the second instance to the session for the same key "A"
It has to unbound the first one : 'U'
and then bound the second instance: 'B'
and finally unbound the second instance : 'U' so answer should be: BUBU

but I ran a program for it and the output was : BBUU ..... am not sure of
how and why that happens.

Thanks for your reply
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic