Search Tutorials


JSP Quiz - MCQ - Multiple Choice Questions | JavaInUse

JSP Quiz - MCQ - Multiple Choice Questions

Q. What is the root object in JSP that provides access to the implicit objects and exposes JSP configuration information?

A. JspContext
B. JspPage
C. JspWriter
D. PageContext

Q. Which tag is used to include static or dynamic resources in a JSP page?

A. <jsp:include>
B. <jsp:forward>
C. <jsp:param>
D. <jsp:useBean>

Q. What is the purpose of the <jsp:useBean> tag in JSP?

A. To create a new instance of a JavaBean
B. To store data in the application scope
C. To forward the request to another JSP page
D. To include a static file in the JSP page

Q. Which scope is available to all JSP pages within the same web application?

A. Page scope
B. Request scope
C. Session scope
D. Application scope

Q. What is the purpose of the <jsp:setProperty> action in JSP?

A. To set the properties of a JavaBean
B. To get the properties of a JavaBean
C. To create a new JavaBean
D. To forward the request to another JSP

Q. Which JSP directive is used to specify the character encoding for the JSP page?

A. <%@ page language="java" contentType="text/html; charset=UTF-8" %>
B. <%@ page language="java" pageEncoding="UTF-8" %>
C. <%@ page language="java" import="java.io.*" %>
D. <%@ page language="java" session="true" %>

Q. What is the purpose of the <jsp:forward> action in JSP?

A. To include a static file in the response
B. To redirect the request to another JSP page
C. To set the properties of a JavaBean
D. To create a new instance of a JavaBean

Q. How can you access the current HTTP request object in a JSP page?

A. request.getRequest()
B. pageContext.getRequest()
C. application.getRequest()
D. session.getRequest()

Q. What is the purpose of the <jsp:param> action in JSP?

A. To set a parameter for a forwarded request
B. To get a parameter from a forwarded request
C. To set a session attribute
D. To get a session attribute





Q. Which JSP tag is used to output the value of an expression to the response?

A. <jsp:expression>
B. <jsp:out>
C. <%= expression %>
D. <jsp:output>

Q. What is the purpose of the <jsp:attribute> action in JSP?

A. To set an attribute on a tag handler
B. To get an attribute from a tag handler
C. To set a request attribute
D. To get a request attribute

Q. How can you declare a variable in a JSP page that is accessible only within that page?

A. <%! int myVar = 10; %>
B. <% int myVar = 10; %>
C. <jsp:variable name="myVar" value="10" />
D. <%@ page var="myVar" value="10" %>

Q. What is the purpose of the <jsp:getProperty> action in JSP?

A. To get a property value from a JavaBean
B. To set a property value on a JavaBean
C. To create a new JavaBean instance
D. To forward the request to another JSP

Q. Which JSP directive is used to specify that the JSP page should only be accessed using HTTPS?

A. <%@ page language="java" contentType="text/html" %>
B. <%@ page language="java" isThreadSafe="true" %>
C. <%@ page language="java" isErrorPage="true" %>
D. <%@ page language="java" isHTTPS="true" %>

Q. What is the purpose of the <jsp:element> action in JSP?

A. To create a new XML element
B. To set the content of an XML element
C. To get the content of an XML element
D. To forward the request to an XML page

Q. What is the purpose of the NgFor directive in Angular?

A. To iterate over an array and display its elements
B. To filter elements in an array
C. To sort an array
D. To create a new array

Q. What is the role of the @Component decorator in Angular?

A. It defines a new component and specifies its metadata
B. It creates a service class
C. It defines a module
D. It injects dependencies

Q. Which statement is true about the lifecycle hooks in Angular?

A. Lifecycle hooks are functions that are automatically called by Angular at specific points in a component\'s lifecycle
B. Lifecycle hooks are only triggered for directives, not components
C. Lifecycle hooks are synchronous and always executed in a specific order
D. Lifecycle hooks are asynchronous and can be executed in any order

Q. What is the purpose of the RouterOutlet component in Angular?

A. To display the current route and its parameters
B. To navigate to a different route
C. To display the component associated with the current route
D. To guard routes and restrict access

Q. What is the purpose of the *ngIf directive in Angular?

A. To display or hide HTML elements based on a condition
B. To iterate over an array
C. To bind data to an input field
D. To handle user events

Q. What is the purpose of the @Input() decorator in Angular?

A. To pass data from a parent component to a child component
B. To retrieve data from a service
C. To bind data to an input field
D. To handle user events

Q. What is the purpose of the @Output() decorator in Angular?

A. To pass data from a child component to a parent component
B. To retrieve data from a service
C. To bind data to an input field
D. To handle user events

Q. What is the purpose of the RouterModule in Angular?

A. To enable routing and navigation between different views
B. To manage HTTP requests and responses
C. To provide form validation and handling
D. To manage application state and data

Q. What is the purpose of the FormsModule in Angular?

A. To provide form validation and handling functionality
B. To enable routing and navigation
C. To manage HTTP requests and responses
D. To provide animation support

Q. What is the purpose of the HttpClientModule in Angular?

A. To make HTTP requests and handle responses
B. To provide form validation and handling
C. To enable routing and navigation
D. To manage application state and data

Q. What is the purpose of the CommonModule in Angular?

A. To provide commonly used directives and pipes
B. To enable routing and navigation
C. To provide form validation and handling
D. To manage application state and data

Q. What is the purpose of the NgClass directive in Angular?

A. To conditionally add or remove CSS classes from an element
B. To bind data to an input field
C. To handle user events
D. To display or hide elements

Q. What is the purpose of the NgStyle directive in Angular?

A. To conditionally apply inline styles to an element
B. To add or remove CSS classes
C. To bind data to an input field
D. To handle user events

Q. What is the purpose of the RouterLink directive in Angular?

A. To create a link that triggers navigation to a different route
B. To display the current route
C. To guard routes and restrict access
D. To display the component associated with the current route