This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Mock exan question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Mock exan question" Watch "Mock exan question" New topic
Author

Mock exan question

Dave Teare
Ranch Hand

Joined: Oct 09, 2002
Posts: 80
Question:
Which of the following are considered ThreadSafe?
context attributes
class variables
request attributes
local variables

The question asks for 2 answers, but is there not only one correct answer, namely local variables?
Thanks for any insight!
--Dave.
Jagdeep Singh
Ranch Hand

Joined: Oct 14, 2002
Posts: 106
Correct answer is "Local variables" & "Request variables". Servlet request object is accessed by only one thread because container creates a new ServletRequest object for each request it receives. Since only one thread service the request at any time, request scope is thread safe and so are variables there in. ( Assuming we are no creating threads in doXXX() methods ).


Jagdeep Singh<br />SCJP;SCWCD;IBM Certified XML Solution Developer;SCBCD1.3
Hafizur Rahman
Ranch Hand

Joined: Sep 05, 2002
Posts: 98
I agree with Jagdeep Singh.


SCJP 2(94%), SCBCD 5.0(86%), SCDJWS(86%), SCEA 5 (I-73%, II/III-88%)
The illiterate of the 21st century will not be those who cannot read and write, but those who cannot learn, unlearn, and relearn. - Alvin Toffler
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mock exan question
 
Similar Threads
Need Answer
request atributes are always thread-safe?
Thread safety
which attribute scopes are thread-safe
Mock Question about thread-safe