My answer would be A, D and F. I think answer C is also wrong - the variable ctx here is not thread safe. There will be one ServletContext for one web application. That means, if there are more than one servlets in the application, they all share the same ServletContext object. Synchronizing access to SErvletContext in one servlet will not guarantee that the SErvletContext object is thread safe.
I am also not able to understand the explanation
obj is not thread safe because even though the ServletContext object is synchronized, its attributes are not. They need to be synchronized separately.
I think obj is an attribute set to the ServletContext, and can be accessed from all the servlets in the web application, hence it is also not thread safe.
Joined: Sep 14, 2005
Thanks Gouri. I am able to understand what you are trying to say. It's a very tricky question with a lot of assumptions.