File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes EduardoCobian Q 29 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "EduardoCobian Q 29" Watch "EduardoCobian Q 29" New topic

EduardoCobian Q 29

Tracy Woo
Ranch Hand

Joined: Jul 23, 2002
Posts: 113

Which statements are correct regarding the following jsp lines that use a tag library?
<%! Vectot vector =new java.util.Vector();%>
<% vector.addElement(“one” ; vector.addElement(“two” ; %>
<prefix:suffix attr='vector' />
1) A vector can't be assigned to a tag handler attribute
2) The program will compile and assign the vector's content to the attribute attr.
3) The program will assign the content of vector if assigment is: attr='<%= vector %>'
4) Microsoft is the worst software company in history.

The given answer is 3. But I am unable to understand what is meant by "the content of vector".
Can somebody please explain?
Kyle Tang
Ranch Hand

Joined: Aug 22, 2002
Posts: 78
attr="vector" means, the string literal "vector" is assigned to that attr. in this case, attr has type String.
attr="<%=vector%> means, attr has type Vector, and it is assigned value vector. In this case, I guess you need to explicitly define the type for attr, in the tld file.
content of the vector means, the real Vector object, not just the String "vector".

Kyle Tang<br />SCJP 91<br />SCWCD 96<br />SCBCD 95
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 671
I feel this question is unclear.
<prefix:suffix attr='vector' /> means a string ‘vector’ is assigned to attr. I think this is OK.
I think 1) is true: A vector can't be assigned to a tag handler attribute.
I hope some one can clear this up since I am not very sure about this.

We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design

Crazy Bikes created by m-Power
Tauqueer Ali
Ranch Hand

Joined: Sep 05, 2001
Posts: 53
I faced a very similar question in actual SCWCD exam.

SCJP2, SCWCD, XML, OOAD<br />Kolkata, India
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
The JSP fragmentwill translate to (among other things) the statementwhere "tag" is a variable referring to the tag object, and "expr" can be any Java expression or variable (including a Java primitive). Of course, if the tag does not have a setAttr() method taking an appropriate argument type, the compiler will complain.
Still a bad question because I feel that 3. and 4. are equally correct
- Peter
I agree. Here's the link:
subject: EduardoCobian Q 29
It's not a secret anymore!