Below are the Answers to the Questions that were part of the Practice Exam in the previous chapter. If the answer you chose matches the answer given here, great. In case it doesn't, don't worry. Just revisit the chapter that covers the topic and revise the chapter. You will be able to crack the exams easily!!!
Answers:
QUESTION 1:
A and D.
Question 2:
A and D.
Question 3:
C.
Question 4:
A, C, and D.
Question 5:
A and D.
Question 6:
B and D.
Question 7:
B.
Question 8:
D.
Question 9:
B and D.
Question 10:
A.
Question 11:
A and D.
Question 12:
D.
Question 13:
A.
Question 14:
C.
Question 15:
B.
Question 16:
D.
Question 17:
C and E.
Question 18:
A and B.
Question 19:
A and B.
Question 20:
B.
Question 21:
A and C.
Question 22:
C and D.
Question 23:
A and B.
Question 24:
A.
Question 25:
C and D.
Question 26:
A.
Question 27:
B and D.
Question 28:
C.
Question 29:
D.
Question 30:
C.
Question 31:
B and C.
Question 32:
A and C.
Question 33:
B.
Question 34:
B and C.
Question 35:
A.
Question 36:
A and B.
Question 37:
A and B.
Question 38:
A.
Question 39:
B.
Question 40:
B.
Question 41:
service.
Question 42:
A and C.
Question 43:
B and C.
Question 44:
B.
Question 45:
A and B.
Question 46:
C.
Question 47:
C and D.
Question 48:
A.
Question 49:
C and D.
Question 50:
A.
Question 51:
A.
Question 52:
D.
Question 53:
D.
Question 54:
B and C.
Question 55:
A.
Question 56:
A.
Question 57:
A and B.
Question 58:
C.
Question 59:
A.
Question 60:
A.
Previous Chapter: SCWCD Mock Exam 1
Next Chapter: SCWCD Mock Exam 2
Topics Covered in the Blog - Synopsis
Showing posts with label sample questions scwcd. Show all posts
Showing posts with label sample questions scwcd. Show all posts
Friday, April 29, 2011
Self Test: Chapters 51 to 58
Questions
Question 1
Which design pattern has as its primary responsibility to decouple presentation and service tiers, and a central director?
A. Value Object
B. Composite View
C. Business Delegate
D. Model-View-Controller
Question 2
Which design pattern has as its primary responsibility to exchange data between tiers?
A. Value Object
B. Composite View
C. Business Delegate
D. Model-View-Controller
Question 3
Which design pattern has as its primary responsibility to abstract data sources and provide transparent access to the data in these sources?
A. Value Object
B. Data Access Object
C. Business Delegate
D. Model-View-Controller
E. None of the above
Question 4
Which design pattern has as its primary responsibility to isolate the presentation and the business tiers from each other by adding a director between the two, making it is easier to manage changes on either side?
A. Session Facade
B. Data Access Object
C. Business Delegate
D. Model-View-Controller
E. Aggregate Entity
Question 5
Which one of the following is most likely used for cache?
A. Value Object
B. Data Access Object
C. Business Delegate
D. Cache Object
E. Aggregate Entity
Question 6
Which design pattern acts as a switchboard, dispatching incoming requests to the correct resource?
A. Value Object
B. Data Access Object
C. Business Delegate
D. Front Controller
Question 7
Which design pattern is most likely to care about RDBMS, OODBMS, and flat files?
A. Value Object
B. Data Access Object
C. Business Delegate
D. Cache Object
E. Aggregate Entity
Question 8
Which design pattern does the following force most affect?
Persistent storage APIs vary between vendors, which causes a lack of uniform APIs to address the requirements for accessing storages.
A. Value Object
B. Data Access Object
C. Business Delegate
D. Cache Object
E. Aggregate Entity
Question 9
Which design pattern has as its primary role to provide control and protection for the business service?
A. Value Object
B. Data Access Object
C. Business Delegate
D. Cache Object
E. Aggregate Entity
Question 10
Which design pattern is most likely to be used as a proxy?
A. Business Delegate
B. Data Access Object
C. Model-View-Controller
D. Value Object
Question 11
Which design pattern reduces the number of remote network method calls required to obtain the attribute values from the entity beans?
A. Business Delegate
B. Data Access Object
C. Model-View-Controller
D. Value Object
Question 12
Which design pattern that usually is a good candidate to work with entity beans becomes less useful when a cache is used to persist data?
A. Business Delegate
B. Data Access Object
C. Model-View-Controller
D. Value Object
Answers
Question 1
D. The Model-View-Controller pattern has as its primary responsibility to decouple presentation and data/business logic tiers, by using a director or switchboard between them.
Question 2
A. The Value Object pattern has as its primary responsibility to exchange data between tiers. Although the Business Delegate and Model-View-Controller also do this, it isn't their primary responsibility.
Question 3
B. The Data Access Object pattern has as its primary responsibility to abstract data sources and provide transparent access to the data in these sources. The Business Delegate and Model-View-Controller may do so, but the Data Access Object always does this.
Question 4
D. The Model-View-Controller pattern has as its primary responsibility to minimize the impact of changing the client or business tier. Remember that this is a very high-level pattern, so it often uses other patterns.
Question 5
A. The Value Object pattern is most likely used for cache. Notice that its whole purpose is to collect data from somewhere far and bring it close in a neat package. The Data Access Object and Business Delegate often actually use a Value Object underneath. The Cache Object is fiction and the Aggregate Entity is not one of the four that you might see on the exam.
Question 6
D. The front controller pattern acts as a switch board, dispatching incoming requests to the correct resource.
Question 7
B. The Data Access Object design pattern is one that deals with RDBMS, OODBMS, excel, flat files, and more. This is pattern you use to isolate the access API from the actual data repository implementation. Value Object and Business Delegate don't do this. The other two patterns mentioned are distracters.
Question 8
B. The Data Access Object design pattern is affected most by varying persistent storage APIs due to different vendors and non-uniform APIs to address the requirements to access storages. Whenever you see the word persistent, think Data Access Object design pattern.
Question 9
C. The Business Delegate design pattern has as its primary role to provide control and protection for the business service. Although you can't just ignore the rest of the Question, normally when a Question focuses on the business service, think Business Delegate design pattern.
Question 10
A. The Business Delegate design pattern is most likely to be used as a proxy. Its whole purpose is being the mediator between a business service and the rest of the world, especially, but not limited to, clients. This is what proxies do, too.
Question 11
D. The Value Object design pattern reduces the number of remote network method calls required to obtain the attribute values from the entity beans. Although the four patterns in the answers do this, it's the main reason for using a Value Object.
Question 12
B. The Data Access Object design pattern is usually a good candidate to work with data that is remote or and costly to query often, but becomes a bad choice with container-managed persistence. This is tricky because the container often, but not always, will persist data as a primary function.
Previous Chapter: Quick Recap - Chapters 51 to 58
Next Chapter: Chapter 59 - Exam Preparation Tips
Question 1
Which design pattern has as its primary responsibility to decouple presentation and service tiers, and a central director?
A. Value Object
B. Composite View
C. Business Delegate
D. Model-View-Controller
Question 2
Which design pattern has as its primary responsibility to exchange data between tiers?
A. Value Object
B. Composite View
C. Business Delegate
D. Model-View-Controller
Question 3
Which design pattern has as its primary responsibility to abstract data sources and provide transparent access to the data in these sources?
A. Value Object
B. Data Access Object
C. Business Delegate
D. Model-View-Controller
E. None of the above
Question 4
Which design pattern has as its primary responsibility to isolate the presentation and the business tiers from each other by adding a director between the two, making it is easier to manage changes on either side?
A. Session Facade
B. Data Access Object
C. Business Delegate
D. Model-View-Controller
E. Aggregate Entity
Question 5
Which one of the following is most likely used for cache?
A. Value Object
B. Data Access Object
C. Business Delegate
D. Cache Object
E. Aggregate Entity
Question 6
Which design pattern acts as a switchboard, dispatching incoming requests to the correct resource?
A. Value Object
B. Data Access Object
C. Business Delegate
D. Front Controller
Question 7
Which design pattern is most likely to care about RDBMS, OODBMS, and flat files?
A. Value Object
B. Data Access Object
C. Business Delegate
D. Cache Object
E. Aggregate Entity
Question 8
Which design pattern does the following force most affect?
Persistent storage APIs vary between vendors, which causes a lack of uniform APIs to address the requirements for accessing storages.
A. Value Object
B. Data Access Object
C. Business Delegate
D. Cache Object
E. Aggregate Entity
Question 9
Which design pattern has as its primary role to provide control and protection for the business service?
A. Value Object
B. Data Access Object
C. Business Delegate
D. Cache Object
E. Aggregate Entity
Question 10
Which design pattern is most likely to be used as a proxy?
A. Business Delegate
B. Data Access Object
C. Model-View-Controller
D. Value Object
Question 11
Which design pattern reduces the number of remote network method calls required to obtain the attribute values from the entity beans?
A. Business Delegate
B. Data Access Object
C. Model-View-Controller
D. Value Object
Question 12
Which design pattern that usually is a good candidate to work with entity beans becomes less useful when a cache is used to persist data?
A. Business Delegate
B. Data Access Object
C. Model-View-Controller
D. Value Object
Answers
Question 1
D. The Model-View-Controller pattern has as its primary responsibility to decouple presentation and data/business logic tiers, by using a director or switchboard between them.
Question 2
A. The Value Object pattern has as its primary responsibility to exchange data between tiers. Although the Business Delegate and Model-View-Controller also do this, it isn't their primary responsibility.
Question 3
B. The Data Access Object pattern has as its primary responsibility to abstract data sources and provide transparent access to the data in these sources. The Business Delegate and Model-View-Controller may do so, but the Data Access Object always does this.
Question 4
D. The Model-View-Controller pattern has as its primary responsibility to minimize the impact of changing the client or business tier. Remember that this is a very high-level pattern, so it often uses other patterns.
Question 5
A. The Value Object pattern is most likely used for cache. Notice that its whole purpose is to collect data from somewhere far and bring it close in a neat package. The Data Access Object and Business Delegate often actually use a Value Object underneath. The Cache Object is fiction and the Aggregate Entity is not one of the four that you might see on the exam.
Question 6
D. The front controller pattern acts as a switch board, dispatching incoming requests to the correct resource.
Question 7
B. The Data Access Object design pattern is one that deals with RDBMS, OODBMS, excel, flat files, and more. This is pattern you use to isolate the access API from the actual data repository implementation. Value Object and Business Delegate don't do this. The other two patterns mentioned are distracters.
Question 8
B. The Data Access Object design pattern is affected most by varying persistent storage APIs due to different vendors and non-uniform APIs to address the requirements to access storages. Whenever you see the word persistent, think Data Access Object design pattern.
Question 9
C. The Business Delegate design pattern has as its primary role to provide control and protection for the business service. Although you can't just ignore the rest of the Question, normally when a Question focuses on the business service, think Business Delegate design pattern.
Question 10
A. The Business Delegate design pattern is most likely to be used as a proxy. Its whole purpose is being the mediator between a business service and the rest of the world, especially, but not limited to, clients. This is what proxies do, too.
Question 11
D. The Value Object design pattern reduces the number of remote network method calls required to obtain the attribute values from the entity beans. Although the four patterns in the answers do this, it's the main reason for using a Value Object.
Question 12
B. The Data Access Object design pattern is usually a good candidate to work with data that is remote or and costly to query often, but becomes a bad choice with container-managed persistence. This is tricky because the container often, but not always, will persist data as a primary function.
Previous Chapter: Quick Recap - Chapters 51 to 58
Next Chapter: Chapter 59 - Exam Preparation Tips
Thursday, April 28, 2011
Self Test: Chapters 44 & 45
Questions
Question 1:
Which three of the following is part of the Tag Library Descriptor element?
A. namespace
B. name
C. tag handler class
D. tag attributes
Question 2:
Which two of the following attributes are not part of the taglib directive?
A. url
B. uri
C. prefix
D. name
Question 3:
Which file does the following DTD element definition apply to: ?
A. web.init
B. YourTagHandler.java
C. YourTagLibraryDefinition.tld
D. web.xml
Question 4:
Which of the following is the Web Deployment Descriptor, the purpose of which is to configure a Web application?
A. web.xml
B. web.init
C. YourTagLibraryDefinition.tld
D. YourTagHandler.java
Question 5:
Which three of the following files is part of a simple tag library?
A. web.xml
B. web.init
C. YourTagLibraryDefinition.tld
D. YourTagHandler.java
Question 6:
How do you declare a tag library within a JSP page?
A. You use a declare scriptlet.
B. You use a taglib directive.
C. You use a unique variable.
D. You use the path to the tag handler.
Question 7:
Which two of the following options apply to an empty custom tag?
A. Specified in the web.xml Web component descriptor.
B. Specified in the tag library handler.
C. < libraryPrefix : handlerName / >
D. A custom tag with no body.
Question 8:
What does the container use to validate a custom tag in a JSP page?
A. web.xml
B. Xerces
C. Xmlspy
D. Tag Library Descriptor
Question 9:
Which interface does the doStartTag() belong to?
A. TagSupport
B. TagProcess
C. Tag
D. TagStart
Question 10:
What does the container do during translation when it encounters a custom tag in a JSP page?
A. It converts the XML notation into Java calls, inserted into the Java that resulted from the page translation.
B. It passes it to the tag handler.
C. It converts it to scriptlets.
D. It adds the code to the output stream.
Answers:
Question 1:
B, C, and D. All of these are part of the Tag Library Descriptor element except option A. Also, you need a JSP file such as yourJSP.jsp.
Question 2:
A and D. The taglib directive only takes two attributes, uri and prefix.
Question 3:
D. The taglib element is used to describe a JSP tag library. The syntax for the taglib element in the web.xml file is < ! ELEMENT taglib (taglib-uri, taglib-location) >. The required taglib-location element contains the location and the taglib-uri element describes a URI identifying a Tag Library used in the Web application. You use the URI to give a tag library a unique address or namespace.
Question 4:
A. The web.xml file is used as the deployment descriptor. The deployment descriptor defines the elements and configuration information of a Web application. In it you define elements to support the Web application within a servlet container, including ServletContext init parameters, session configuration, and servlet declarations..”
Note: We will be covering Deployment & Deployment Descriptions shortly. So for now, just know this about the web.xml file.
Question 5:
A, C, and D. All of these files could be used as part of your tag library except option B because web.init is not a file defined by the specification. Also, you need a JSP file such as yourJSP.jsp.
Question 6:
B. The taglib directive creates a reference to the prefix. The prefix tells the container which library you want. Once that is done, you can use a custom tag, so called because it is your tag, not a standard one that came shipped with the container.
Question 7:
C and D. C uses correct XML notation to refer to an empty tag. By convention, we call a custom tag in a JSP page without a body an empty custom tag.
Question 8:
D. The Tag Library Descriptor (TLD) is used by a Web container to validate the tags in a JSP page.
Question 9:
A. Your tag handler is a class that extends the TagSupport abstract class if it has doStartTag() and doEndTag() methods.
Question 10:
A. The container will combine the JSP code and tag library into one Java source file. The container converts your custom tags into Java calls during the JSP page translation.
Previous Chapter: Quick Recap - Chapters 44 & 45
Next chapter: chapter 46 - JSP API
Question 1:
Which three of the following is part of the Tag Library Descriptor element?
A. namespace
B. name
C. tag handler class
D. tag attributes
Question 2:
Which two of the following attributes are not part of the taglib directive?
A. url
B. uri
C. prefix
D. name
Question 3:
Which file does the following DTD element definition apply to: ?
A. web.init
B. YourTagHandler.java
C. YourTagLibraryDefinition.tld
D. web.xml
Question 4:
Which of the following is the Web Deployment Descriptor, the purpose of which is to configure a Web application?
A. web.xml
B. web.init
C. YourTagLibraryDefinition.tld
D. YourTagHandler.java
Question 5:
Which three of the following files is part of a simple tag library?
A. web.xml
B. web.init
C. YourTagLibraryDefinition.tld
D. YourTagHandler.java
Question 6:
How do you declare a tag library within a JSP page?
A. You use a declare scriptlet.
B. You use a taglib directive.
C. You use a unique variable.
D. You use the path to the tag handler.
Question 7:
Which two of the following options apply to an empty custom tag?
A. Specified in the web.xml Web component descriptor.
B. Specified in the tag library handler.
C. < libraryPrefix : handlerName / >
D. A custom tag with no body.
Question 8:
What does the container use to validate a custom tag in a JSP page?
A. web.xml
B. Xerces
C. Xmlspy
D. Tag Library Descriptor
Question 9:
Which interface does the doStartTag() belong to?
A. TagSupport
B. TagProcess
C. Tag
D. TagStart
Question 10:
What does the container do during translation when it encounters a custom tag in a JSP page?
A. It converts the XML notation into Java calls, inserted into the Java that resulted from the page translation.
B. It passes it to the tag handler.
C. It converts it to scriptlets.
D. It adds the code to the output stream.
Answers:
Question 1:
B, C, and D. All of these are part of the Tag Library Descriptor element except option A. Also, you need a JSP file such as yourJSP.jsp.
Question 2:
A and D. The taglib directive only takes two attributes, uri and prefix.
Question 3:
D. The taglib element is used to describe a JSP tag library. The syntax for the taglib element in the web.xml file is < ! ELEMENT taglib (taglib-uri, taglib-location) >. The required taglib-location element contains the location and the taglib-uri element describes a URI identifying a Tag Library used in the Web application. You use the URI to give a tag library a unique address or namespace.
Question 4:
A. The web.xml file is used as the deployment descriptor. The deployment descriptor defines the elements and configuration information of a Web application. In it you define elements to support the Web application within a servlet container, including ServletContext init parameters, session configuration, and servlet declarations..”
Note: We will be covering Deployment & Deployment Descriptions shortly. So for now, just know this about the web.xml file.
Question 5:
A, C, and D. All of these files could be used as part of your tag library except option B because web.init is not a file defined by the specification. Also, you need a JSP file such as yourJSP.jsp.
Question 6:
B. The taglib directive creates a reference to the prefix. The prefix tells the container which library you want. Once that is done, you can use a custom tag, so called because it is your tag, not a standard one that came shipped with the container.
Question 7:
C and D. C uses correct XML notation to refer to an empty tag. By convention, we call a custom tag in a JSP page without a body an empty custom tag.
Question 8:
D. The Tag Library Descriptor (TLD) is used by a Web container to validate the tags in a JSP page.
Question 9:
A. Your tag handler is a class that extends the TagSupport abstract class if it has doStartTag() and doEndTag() methods.
Question 10:
A. The container will combine the JSP code and tag library into one Java source file. The container converts your custom tags into Java calls during the JSP page translation.
Previous Chapter: Quick Recap - Chapters 44 & 45
Next chapter: chapter 46 - JSP API
Labels:
jsp tag library,
sample questions scwcd,
scwcd exam,
scwcd exam questions,
self test,
self test scwcd,
taglibs
| Reactions: |
Thursday, April 14, 2011
Self Test: Chapters 38 to 43
Let us test out our knowledge of JavaBeans that we learnt in the past chapters.
Questions:
Question 1:
Which one of the following interfaces is implemented when declaring a JavaBean?
A. JavaBean
B. ServiceBean
C. HttpJavaBean
D. ServletBean
E. None of the above.
Question 2:
Which one of the following objects is passed to a JavaBean when one of its properties is set via a JSP action?
A. ServletRequest
B. HttpServletRequest
C. ServletResponse
D. HttpServletResponse
E. None of the above.
Question 3:
By default, how many instances of a JavaBean will be created by a servlet container when there are five useBean elements with the same ID on the same JSP page?
A. One
B. Five
C. One per session
D. None of the above
Question 4:
Which of the following cannot be used as the scope when using a JavaBean with JSP?
A. response
B. request
C. session
D. application
E. page
Question 5:
Which of the following are used by servlet containers to set JavaBean properties?
A. cookies
B. form fields
C. memory
D. disk
Question 6:
Which of the following scopes best fits with this description: “An object inside this scope is accessible from all pages processing the request during which the object was created?”
A. page
B. session
C. application
D. request
Question 7:
Is it impossible to share a page scope variable with another JSP or servlet?
A. Yes
B. No
C. Sometimes
D. Configurable
Question 8:
Given a form field named lastName, what is the get method for the associatedJavaBean property?
public String getFirstName ()
{
return firstName;
}
public String getFirstName (boolean returnValue)
{
if (returnValue)
return firstName;
}
public String getFirstname ()
{
return Firstname;
}
public String get("FirstName")
{
return FirstName;
}
Answers:
Answer 1:
E. None of the interfaces mentioned in the answers is implemented when declaring a JavaBean. It isn't an interface that makes a class a JavaBean; it's the way it is used with a public class, public constructor without arguments, and the get/set paradigm. Notice that neither “none of the above” nor “all of the above” answers are allowed on the actual exam.
Answer 2:
E. None of the objects mentioned in the answers is passed to a JavaBean when a property is changed from JSP. Rather, it is simply a method call transferred from the JSP page to the Bean with either the setProperty element or with a direct call within a scriptlet
Answer 3:
D. There will only be one instance of a JavaBean with the same ID created by a servlet container, even when there are five useBean actions on the same JSP page. If you have more than one useBean action with the same ID, you will get a CompileException for the duplicate bean name. See “Creating JavaBeans,” earlier in this chapter.
Answer 4:
A. The response object cannot be used as the scope when using a JavaBean with JSP.
Answer 5:
B. The JavaBean attributes are set when the container captures the form field name-value pairs, and then calls the setter methods in the bean for the attributes which have the same name as the form fields.
Answer 6:
D. The request scope best fits the description given by the question.
Answer 7:
A. This is true that it is impossible to share a page scoped variable with another JSP or Servlet.
Answer 8:
B. When you write a get method for a JavaBean property, use set or get followed by the first letter of the property name capitalized.
Previous Chapter: Quick Recap - Chapters 38 to 43
Next Chapter: Chapter 44 - JSP Tag Libraries
Questions:
Question 1:
Which one of the following interfaces is implemented when declaring a JavaBean?
A. JavaBean
B. ServiceBean
C. HttpJavaBean
D. ServletBean
E. None of the above.
Question 2:
Which one of the following objects is passed to a JavaBean when one of its properties is set via a JSP action?
A. ServletRequest
B. HttpServletRequest
C. ServletResponse
D. HttpServletResponse
E. None of the above.
Question 3:
By default, how many instances of a JavaBean will be created by a servlet container when there are five useBean elements with the same ID on the same JSP page?
A. One
B. Five
C. One per session
D. None of the above
Question 4:
Which of the following cannot be used as the scope when using a JavaBean with JSP?
A. response
B. request
C. session
D. application
E. page
Question 5:
Which of the following are used by servlet containers to set JavaBean properties?
A. cookies
B. form fields
C. memory
D. disk
Question 6:
Which of the following scopes best fits with this description: “An object inside this scope is accessible from all pages processing the request during which the object was created?”
A. page
B. session
C. application
D. request
Question 7:
Is it impossible to share a page scope variable with another JSP or servlet?
A. Yes
B. No
C. Sometimes
D. Configurable
Question 8:
Given a form field named lastName, what is the get method for the associatedJavaBean property?
public String getFirstName ()
{
return firstName;
}
public String getFirstName (boolean returnValue)
{
if (returnValue)
return firstName;
}
public String getFirstname ()
{
return Firstname;
}
public String get("FirstName")
{
return FirstName;
}
Answers:
Answer 1:
E. None of the interfaces mentioned in the answers is implemented when declaring a JavaBean. It isn't an interface that makes a class a JavaBean; it's the way it is used with a public class, public constructor without arguments, and the get/set paradigm. Notice that neither “none of the above” nor “all of the above” answers are allowed on the actual exam.
Answer 2:
E. None of the objects mentioned in the answers is passed to a JavaBean when a property is changed from JSP. Rather, it is simply a method call transferred from the JSP page to the Bean with either the setProperty element or with a direct call within a scriptlet
Answer 3:
D. There will only be one instance of a JavaBean with the same ID created by a servlet container, even when there are five useBean actions on the same JSP page. If you have more than one useBean action with the same ID, you will get a CompileException for the duplicate bean name. See “Creating JavaBeans,” earlier in this chapter.
Answer 4:
A. The response object cannot be used as the scope when using a JavaBean with JSP.
Answer 5:
B. The JavaBean attributes are set when the container captures the form field name-value pairs, and then calls the setter methods in the bean for the attributes which have the same name as the form fields.
Answer 6:
D. The request scope best fits the description given by the question.
Answer 7:
A. This is true that it is impossible to share a page scoped variable with another JSP or Servlet.
Answer 8:
B. When you write a get method for a JavaBean property, use set or get followed by the first letter of the property name capitalized.
Previous Chapter: Quick Recap - Chapters 38 to 43
Next Chapter: Chapter 44 - JSP Tag Libraries
| Reactions: |
Tuesday, April 12, 2011
Self Test: Chapters 31 to 37
Questions:
Question 1:
Assume the custom tag is GLOOP and the prefix is TWONG. Which of the following is the syntax for an empty custom tag?
A. < TWONG : GLOOP / >
B. < GLOOP : TWONG / >
C. < GLOOP : TWONG > < / GLOOP : TWONG >
D. < TWONG : GLOOP > < / TWONG : GLOOP >
Question 2:
Which design pattern did the designers of JSP use to provide centralized dispatching of requests via a controller servlet?
A. Model-View-Controller
B. Facade
C. Server-Client
D. Publish-Subscribe
Question 3:
Which of the following options is a valid declaration?
A. < % ! String name="Rocky" % >
B. < % ! String name="Rocky"; % >
C. < % String name="Anand" % >
D. < % public String name="Anand"; % >
Question 4:
The following are the contents of comment.jsp:
1 < html >
2 < head > < title >Two Comments< / title > < / head >
3 < body >
4 < % - - JSP Comment - - % >
5 < ! - - HTML Comment - - >
6 < / body >
7 < / html >
Which option best describes what happens upon executing index.jsp?
A. A fatal error occurs because the body is empty.
B. Line 5 (but not 4) gets added to the output stream.
C. 4 (but not 5) gets added to the output stream.
D. All seven lines get added to the output stream.
Question 5:
The following are the contents of request_parameter.jsp:
< html >
< head >
< title >Retrieve Request Parameter< / title >
< / head >
< body >
< % String customerName = request.getParameter("customer"); % >
< p >
The customer is < % = customerName % >
< / body >
< / html >
Assuming the www.que.com server is responding correctly and the page path is valid, what displays in the browser if the user types http://www.quepublishing.com/customer/request_parameter.jsp?customer=Anand?
A. The customer is
B. A blank page.
C. The customer is Anand
D. An error page.
Question 6:
The following are the contents of welcomeHeader.inc:
< h1 >Welcome to our drive through
Java coding service!< / h1 >
The following are the contents of index.jsp:
< html >
< head > < title >Java Quick Code< / title > < / head >
< body >
< % String file="welcomeHeader.inc"; % >
< %@ include file="file" % > < p >
We are the best J2EE Programmers.
< / body >
< / html >
Which option best describes what happens upon executing comment.jsp?
A. An error occurs.
B. The page displays including the welcome header.
C. The page displays excluding the welcome header.
D. The page displays, but replaces the welcome header with the words welcomeHeader.inc.
Question 7:
Which of the following options is a JSP implicit object?
A. objRequest
B. Request.send
C. request
D. servlet
Question 8:
Which of the following options is not a JSP implicit object?
A. out
B. in
C. response
D. page
Question 9:
Which of the following will not compile (assume < x : tag > is a valid custom tag that is declared for the current JSP file)?
A. < % String employees = "Rocky"+"Anand"; % >
B. < x : tag value='< % = "5" % > ' />
C. < x : tag value="< % = "hi!" % > " />
D. < x : tag value='< % = "Joe said \\"" +statement+ "\\"." % > '/ >
Question 10:
Which among the following objects is the best choice to share information between users?
A. application
B. page
C. request
D. session
Question 11:
Which among the following objects is the best choice to share information between pages for a single user?
A. application
B. page
C. request
D. session
Question 12:
Which of the following objects is used to share information between pages using the setAttribute and getAttribute methods?
A. application
B. page
C. request
D. session
Question 13:
Which option is a valid page directive?
A. < % @ page language="java" import="com.myco.*" buffer="16kb" % >
B. < % @ page import="com.myco.class" buffer="16" % >
C. < % @ page language="javaScript" buffer="16" % >
D. < % @ page import='com.myco.*' buffer='16' % >
Question 14:
Which option indicates whether the current JSP page is intended to be the URL target of another JSP page's error page?
A. < % @ page isErrorPage="true" % >
B. < % @ page isErrorPage="/messages/errorPage.jsp" % >
C. < % @ page errorPage="true" % >
D. < % @ page errorPage="/messages/errorPage.jsp" % >
Question 15:
Which option defines a URL to a resource to which any Java programming language Throwable object(s) thrown but not caught by the page implementation are forwarded for error processing?
A. < % @ page isErrorPage="true" % >
B. < % @ page isErrorPage="/messages/errorPage.jsp" % >
C. < % @ page errorPage="true" % >
D. < % @ page errorPage="/messages/errorPage.jsp" % >
Answers:
Answer 1:
A, D. These use the correct syntax for an empty custom tag of GLOOP having the prefix TWONG.
Answer 2:
A. The Model-View-Controller design pattern is the one the designers of JSP use to provide centralized dispatching of requests via a controller servlet.
Answer 3:
B. This is a valid declaration. Be careful about the semicolon, which is required in a declaration.
Answer 4:
B. Remember that the JSP Comment is ignored by the compiler. However, the HTML Comment is passed through. Even though the browser doesn't display content in response to it, the JSP container does add it to the output stream.
Answer 5:
C. The declaration is correct. The customer is < % = customerName % > fragment becomes The customer is Anand.
Answer 6:
A. The following is wrong: < % @ include file="file" % >. It should have been < % @ include file="welcomeHeader.inc" % >. Note that "file" in quotes literally means you were asking the system to include a file whose filename is “file.”
Answer 7:
C. Option C is correct if the request is the only implicit object.
Answer 8:
B. All of these are JSP implicit objects except the fictitious in.
Answer 9:
C. All of these will compile except C, because there are quotes within quotes. It should have been < x : tag value="<%= \"hi!\" %>" / >.
Answer 10:
A. The same application object is accessible by all users.
Answer 11:
D. The session object is the best choice for sharing information between pages for a single user. Users can see their own session object, but can't see others' session objects.
Answer 12:
A, C, and D. Both the application and the session objects can be used to share information between pages with the setAttribute and setAttribute methods. Either A or D is correct. Option C is also valid because you can share attributes from a “master” page to an “included” page.
Answer 13:
A. Only A is correct. All the others are syntactically wrong. Notice the kb requirement on the buffer attribute.
Answer 14:
A. This is the isErrorPage attribute of the page directive. Another page can now, but doesn't have to, use this page as an error page.
Answer 15:
D. The errorPage attribute of the page directive defines a URL to a resource to which any Java programming language Throwable object(s) thrown but not caught by the page implementation are forwarded for error processing.
Previous Chapter: Quick Recap - Chapters 31 to 37
Next Chapter: Chapter 38 - Introduction to JavaBeans
Question 1:
Assume the custom tag is GLOOP and the prefix is TWONG. Which of the following is the syntax for an empty custom tag?
A. < TWONG : GLOOP / >
B. < GLOOP : TWONG / >
C. < GLOOP : TWONG > < / GLOOP : TWONG >
D. < TWONG : GLOOP > < / TWONG : GLOOP >
Question 2:
Which design pattern did the designers of JSP use to provide centralized dispatching of requests via a controller servlet?
A. Model-View-Controller
B. Facade
C. Server-Client
D. Publish-Subscribe
Question 3:
Which of the following options is a valid declaration?
A. < % ! String name="Rocky" % >
B. < % ! String name="Rocky"; % >
C. < % String name="Anand" % >
D. < % public String name="Anand"; % >
Question 4:
The following are the contents of comment.jsp:
1 < html >
2 < head > < title >Two Comments< / title > < / head >
3 < body >
4 < % - - JSP Comment - - % >
5 < ! - - HTML Comment - - >
6 < / body >
7 < / html >
Which option best describes what happens upon executing index.jsp?
A. A fatal error occurs because the body is empty.
B. Line 5 (but not 4) gets added to the output stream.
C. 4 (but not 5) gets added to the output stream.
D. All seven lines get added to the output stream.
Question 5:
The following are the contents of request_parameter.jsp:
< html >
< head >
< title >Retrieve Request Parameter< / title >
< / head >
< body >
< % String customerName = request.getParameter("customer"); % >
< p >
The customer is < % = customerName % >
< / body >
< / html >
Assuming the www.que.com server is responding correctly and the page path is valid, what displays in the browser if the user types http://www.quepublishing.com/customer/request_parameter.jsp?customer=Anand?
A. The customer is
B. A blank page.
C. The customer is Anand
D. An error page.
Question 6:
The following are the contents of welcomeHeader.inc:
< h1 >Welcome to our drive through
Java coding service!< / h1 >
The following are the contents of index.jsp:
< html >
< head > < title >Java Quick Code< / title > < / head >
< body >
< % String file="welcomeHeader.inc"; % >
< %@ include file="file" % > < p >
We are the best J2EE Programmers.
< / body >
< / html >
Which option best describes what happens upon executing comment.jsp?
A. An error occurs.
B. The page displays including the welcome header.
C. The page displays excluding the welcome header.
D. The page displays, but replaces the welcome header with the words welcomeHeader.inc.
Question 7:
Which of the following options is a JSP implicit object?
A. objRequest
B. Request.send
C. request
D. servlet
Question 8:
Which of the following options is not a JSP implicit object?
A. out
B. in
C. response
D. page
Question 9:
Which of the following will not compile (assume < x : tag > is a valid custom tag that is declared for the current JSP file)?
A. < % String employees = "Rocky"+"Anand"; % >
B. < x : tag value='< % = "5" % > ' />
C. < x : tag value="< % = "hi!" % > " />
D. < x : tag value='< % = "Joe said \\"" +statement+ "\\"." % > '/ >
Question 10:
Which among the following objects is the best choice to share information between users?
A. application
B. page
C. request
D. session
Question 11:
Which among the following objects is the best choice to share information between pages for a single user?
A. application
B. page
C. request
D. session
Question 12:
Which of the following objects is used to share information between pages using the setAttribute and getAttribute methods?
A. application
B. page
C. request
D. session
Question 13:
Which option is a valid page directive?
A. < % @ page language="java" import="com.myco.*" buffer="16kb" % >
B. < % @ page import="com.myco.class" buffer="16" % >
C. < % @ page language="javaScript" buffer="16" % >
D. < % @ page import='com.myco.*' buffer='16' % >
Question 14:
Which option indicates whether the current JSP page is intended to be the URL target of another JSP page's error page?
A. < % @ page isErrorPage="true" % >
B. < % @ page isErrorPage="/messages/errorPage.jsp" % >
C. < % @ page errorPage="true" % >
D. < % @ page errorPage="/messages/errorPage.jsp" % >
Question 15:
Which option defines a URL to a resource to which any Java programming language Throwable object(s) thrown but not caught by the page implementation are forwarded for error processing?
A. < % @ page isErrorPage="true" % >
B. < % @ page isErrorPage="/messages/errorPage.jsp" % >
C. < % @ page errorPage="true" % >
D. < % @ page errorPage="/messages/errorPage.jsp" % >
Answers:
Answer 1:
A, D. These use the correct syntax for an empty custom tag of GLOOP having the prefix TWONG.
Answer 2:
A. The Model-View-Controller design pattern is the one the designers of JSP use to provide centralized dispatching of requests via a controller servlet.
Answer 3:
B. This is a valid declaration. Be careful about the semicolon, which is required in a declaration.
Answer 4:
B. Remember that the JSP Comment is ignored by the compiler. However, the HTML Comment is passed through. Even though the browser doesn't display content in response to it, the JSP container does add it to the output stream.
Answer 5:
C. The declaration is correct. The customer is < % = customerName % > fragment becomes The customer is Anand.
Answer 6:
A. The following is wrong: < % @ include file="file" % >. It should have been < % @ include file="welcomeHeader.inc" % >. Note that "file" in quotes literally means you were asking the system to include a file whose filename is “file.”
Answer 7:
C. Option C is correct if the request is the only implicit object.
Answer 8:
B. All of these are JSP implicit objects except the fictitious in.
Answer 9:
C. All of these will compile except C, because there are quotes within quotes. It should have been < x : tag value="<%= \"hi!\" %>" / >.
Answer 10:
A. The same application object is accessible by all users.
Answer 11:
D. The session object is the best choice for sharing information between pages for a single user. Users can see their own session object, but can't see others' session objects.
Answer 12:
A, C, and D. Both the application and the session objects can be used to share information between pages with the setAttribute and setAttribute methods. Either A or D is correct. Option C is also valid because you can share attributes from a “master” page to an “included” page.
Answer 13:
A. Only A is correct. All the others are syntactically wrong. Notice the kb requirement on the buffer attribute.
Answer 14:
A. This is the isErrorPage attribute of the page directive. Another page can now, but doesn't have to, use this page as an error page.
Answer 15:
D. The errorPage attribute of the page directive defines a URL to a resource to which any Java programming language Throwable object(s) thrown but not caught by the page implementation are forwarded for error processing.
Previous Chapter: Quick Recap - Chapters 31 to 37
Next Chapter: Chapter 38 - Introduction to JavaBeans
Labels:
sample questions,
sample questions scwcd,
scwcd exam,
scwcd exam questions,
self test,
self test scwcd
| Reactions: |
Subscribe to:
Posts (Atom)
© 2013 by www.inheritingjava.blogspot.com. All rights reserved. No part of this blog or its contents may be reproduced or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without prior written permission of the Author.
