i just finished completing the final mock exam given in hfsj. i have a doubt in question number 55. it is as follows;
public class ServletX extends HttpServlet{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException {
req.getSession().setAttribute("key",new X());
req.getSession().setAttribute("key",new X());
req.getSession().setAttribute("key","x");
req.getSession().removeAttribute("key");
}
}
public class X implements HttpSessionBinidingListener {
public void valueBound(HttpSessionBindingListener event){
System.out.println("B");
}
public void valueUnbound(HttpSessionBindingListener event){
System.out.println("UB");
}
}
which logging output would be generated by an invocation of the doGet method?
the answer given is - BBUBUB
but i think the answer should be only - BBUB
how come that last UB comes? i means when at the end you remove the attribute you are only removind an attribute who's value is onlya
string and not an object of type X. so how come that UB part comes?
also i just finished the mock exam and scored 56/69. do you guys think this score would be enough for me to take on the real exam?
thank you in advance..