Still preparing for my OCWCD, finding myself in HeadFirst SCWCD 1.4, struggling the final mock-exam.
I am trying to get a feel for the sort and way of questioning.
Page 783, question 41 B: "In all scopes attributes can be retrieved using a getAttribute() method".
According HF this answer is correct. According to my API's, all the getAttribute()-methods have
an argument (String name).
Sooo what do you think, never mind the arguments?
Ok, some quotations to complete the question in question....
Which about web attributes are true?
(Choose all that apply.)
A. No attributes are longer lived than session attributes.
B. In all scopes, attributes can be retrieved using a getAttribute() methode.
C. Context attributes survive a session time-out.
D. Only session and context attributes can be retrieved in an enumeration.
E. Data stored in both request and session objects is thread safe.
HF tells me that B and C are the correct answers, and I agree questionless upon C.
My remark is about the statement made at B's, because the argument to the method (String name)
is omitted. Not mentionned, zippo, gone with the wind, computer says no
And I do see what they mean to ask (that is, I hope...), but, looking forward to the exam,
I hope not be examined in a way of "we hope you've got what we really intended to ask..."
Bottom-line: how exact are questions to be interpreted on the exam.
Thanks for your response!
PS Would there be a difference between asking about a getAttribute() method and asking about the getAttribute() method?
Yea, I guess it's a common problem how to describe a method without specifying what parameters are you interested in.
ExamLab for OCPJP used the "-" character to denote this, like this: getAttribute(-).
It means that whatever arguments the method takes, they're not important - only the name and overall purpose is important for the question.
Frankly, when reading your question, I would undoubtedly say B is correct, as I would treat getAttribute() as it would be written with the (-) thing I talked about above. But the fact remains - I think they should explicitly said what they had on their minds...
By the way: the same problem is with denoting the class which the method comes from. Some books might use the ServletRequest.getAttribute(String) construct, which can be misleading and understood by some users as it's a static method from the ServletRequest class, where the real purpose was to show that the getAttribute(String) method comes from the ServletRequest class.
Once again - you can use more adequate form taken i.e. from the JavaDoc - ServletRequest#getAttribute(String) which shouldn't be problematic from now on.