This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Question about jsp:useBean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Question about jsp:useBean" Watch "Question about jsp:useBean" New topic

Question about jsp:useBean

Botez Nicolae

Joined: Jun 28, 2011
Posts: 4
I am preapring for web component certification and I have a question from a mock exam which confused me. This is the question with the answer:

<jsp:useBean id="baz" class="com.test.Test" type="com.test.Bar" />

Which two are true? (Choose two)

A. An object of type com.test.Test is instantiated and assigned to a variable baz of type com.test.Bar.
B. An object of type com.test.Bar is instantiated and assigned to a variable baz of type com.test.Test.
C. To avoid error, com.test.Bar must be superclass of com.test.Test or an interface implemented by com.test.Test.
D. To avoid error, com.test.Test must be a superclass of com.test.Bar or an interface implemented by com.test.Bar.

Answer: B, D

In my opinion the correct answers are A and C not B, D as it is written in the mock exam. Am I right ? Please help me!
Ashwin Sridhar
Ranch Hand

Joined: Jul 09, 2011
Posts: 272

Yes you are right. Correct answer is A,C.
We try to create object for the Test Class and reference it to Bar class/interface variable baz. OO Concept - Dynamic Polymorphism.
So, Bar can be either abstract class which is extended by Test Class or Interface implemented by Test Class or simply any class or interface higher up in the inheritance hierachy of Test Class.

Ashwin Sridhar
Botez Nicolae

Joined: Jun 28, 2011
Posts: 4
Thanks a lot!
Avinash Ga
Ranch Hand

Joined: Aug 13, 2011
Posts: 78

Yes nicolae, you are right. The correct answers are A and C. Some times authors will make mistakes and some times that is intentional it seems, don't get confused and stick to your basics.

Avinash G.A
OCP Java SE 6 Programmer, OCP Java EE 5 Web Component Developer, OCE Java EE 6 Web Services Developer, VMware Certified Core Spring 3.x Developer, EMC Proven Professional (ISM-V2)
I agree. Here's the link:
subject: Question about jsp:useBean
Similar Threads
Jaworski mock - statements on non-static inner class
please give me answer of these question soon
instanceof operator
Weblogic 7.0 certification mock test question