This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma 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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Mock exan question" Watch "Mock exan question" New topic

Mock exan question

Dave Teare
Ranch Hand

Joined: Oct 09, 2002
Posts: 80
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!
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:
subject: Mock exan question
It's not a secret anymore!