A class wants to keep track of its number of objects being added to HttpSession objects. Which will be the ideal way to achieve this?

  1. Define a listener class implementing HttpSessionListener and whenever an object is added to Http Session object, keep track of the number of instances.

  2. Define a listener class implementing HttpSessionBindingListener and in the valueBound() method, keep track of the number of instances being added in a static variable.

  3. It is highly impossible to keep track the number of objects being added to a Http Session in a Web Application.

  4. The Servlet API provides direct support for keeping track the object instances.


Correct Option: B

Find more quizzes: