This will give you a compiler error because the get(int, int) method says it returns a BitSet object rather than a Test object. We, of course, know better. We can add an explicit cast to make the code compile:
code:
--------------------------------------------------------------------------------
Test t = new Test();Test t1 = (Test)t.get(0,0);
--------------------------------------------------------------------------------
I don't really know if that answered your question or not, but it's a start. If you're still confused, try to explain what you're after a little more and I'll try to help.
Choose the correct one:
a.) MyServlet is thread safe.
b.) MyServlet is not thread safe because myName is an instance variable.
c.) MyServlet is not thread safe because MyServlet implements SingleThreadModel.
d.) None of the above.
Correct choice
A
Explanation
Choice A is correct. An application is thread safe if it always behaves predictably regardless of the number of concurrent threads running in its process space. The simplest way to ensure that a servlet is thread safe is to implement the SingleThreadModel interface. By implementing this interface, the server guarantees that no more than one thread can execute the service(), doGet(), or doPost() method at a time for a particular servlet instance. This makes the servlet thread safe. Thus even if class MyServlet has instance variables, it is thread safe. Thus A is the correct choice and the other choices are incorrect.