Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Chapter: 38
Q581:
What does the pageContext.getOut() method return?
A. A database connection
B. An output stream for the JSP
C. A reference to the request object
D. The current page context
Correct Answer:
B
Chapter: 38
Q582:
How do you specify a custom tag's attribute in the Tag Library Descriptor (TLD) file?
A. Using <attribute> element
B. Using <tag> element
C. Using <name> element
D. Using <body-content> element
Correct Answer:
A
Chapter: 38
Q583:
What is the typical role of the display() method in a tag handler class?
A. To format and output HTML content
B. To handle form submissions
C. To create database connections
D. To initialize the tag handler
Correct Answer:
A
Chapter: 38
Q584:
What is the purpose of the setPageName() method in the custom tag handler?
A. To set the tag's display name
B. To initialize the tag handler class
C. To assign a value to the tag attribute
D. To create an instance of a tag
Correct Answer:
C
Chapter: 38
Q585:
In which file do you define the prefix and URI for a custom tag library?
A. index.jsp
B. controller.jsp
C. web.jsp
D. customtags.tld
Correct Answer:
D
Chapter: 38
Q586:
What type of custom tag has no body and no attributes?
A. Simple Tag
B. Tag with Attributes
C. Tag with Body
D. Empty Tag
Correct Answer:
A
Chapter: 38
Q587:
How is a custom tag with attributes typically called in a JSP page?
A. <mytag:tag attribute="value" />
B. <mytag:tag />
C. <mytag:tag>
D. <tag:mytag attribute="value" />
Correct Answer:
A
Chapter: 39
Q588:
What does the taglib directive in JSP allow you to do?
A. Import Java classes
B. Declare a tag library for use
C. Define custom tag attributes
D. Specify JSP content types
Correct Answer:
B
Chapter: 39
Q589:
Where should the .tld file be placed in the web application directory structure?
A. /WEB-INF/classes
B. /WEB-INF/tlds
C. /WEB-INF
D. /WEB-INF/lib
Correct Answer:
B
Chapter: 39
Q590:
What should the body-content element in the TLD file be set to for a tag without a body?
A. empty
B. scriptless
C. tagdependent
D. body
Correct Answer:
A
Chapter: 39
Q591:
What is the purpose of the isErrorPage attribute in JSP?
A. To declare a JSP as an error page
B. To define the page title
C. To set the page language
D. To link pages together
Correct Answer:
A
Chapter: 39
Q592:
How does the errorPage attribute in JSP work?
A. It defines the page that handles errors
B. It sets the default error message
C. It links to external CSS stylesheets
D. It provides database connection details
Correct Answer:
A
Chapter: 39
Q593:
In the Address Book example, what is the role of PersonDAO?
A. To handle database operations
B. To display the user interface
C. To manage session data
D. To validate user inputs
Correct Answer:
A
Chapter: 39
Q594:
Which JSP page is responsible for saving a new person’s information in the Address Book example?
A. addperson.jsp
B. saveperson.jsp
C. searchperson.jsp
D. showperson.jsp
Correct Answer:
B
Chapter: 39
Q595:
How is showperson.jsp used in the Address Book application?
A. To display the result of a person search
B. To add new person information
C. To handle errors during database operations
D. To display a form for adding new persons
Correct Answer:
A
Chapter: 39
Q596:
What does the addbookerror.jsp page do when an exception occurs?
A. Displays an error message and the exception type
B. Redirects to the homepage
C. Saves error details to a file
D. Logs the error details to the console
Correct Answer:
A
Chapter: 39
Q597:
Which MVC component is responsible for handling user input and updating the model?
A. View
B. Controller
C. Model
D. Database
Correct Answer:
B
Chapter: 40
Q598:
In the MVC architecture, what does the 'Model' component represent?
A. The state of the application
B. The user interface
C. The data access layer
D. The application’s security features
Correct Answer:
A
Chapter: 40
Q599:
What is a key difference between MVC Model 1 and Model 2?
A. Model 1 does not separate view and controller
B. Model 2 has a decentralized view selection
C. Model 1 uses servlets for data processing
D. Model 2 requires less coding in JSP pages
Correct Answer:
A
Chapter: 40
Q600:
What happens if an exception occurs on addperson.jsp?
A. It redirects to addbookerror.jsp
B. It shows an error message on the same page
C. It logs the error in a file
D. It automatically retries the operation
Correct Answer:
A