Show List

Quiz - Spring MVC - 1

57%

Public Average Score
Select the right answer for below questions:

What is the purpose of a Spring MVC Controller?
To manage the data model
To render the view
To handle user requests and return appropriate response
To handle authentication and authorization
To handle user requests and return appropriate response

What is the difference between a Filter and an Interceptor in Spring MVC?
Filters operate at the controller level, while interceptors operate at the servlet level
Filters and interceptors are the same thing
Filters and interceptors are not related to each other
Filters operate at the servlet level, while interceptors operate at the controller level
Filters operate at the servlet level, while interceptors operate at the controller level

How can you handle exceptions in Spring MVC?
By using the @ExceptionHandler annotation on a controller method
By implementing the HandlerExceptionResolver interface
By using the @ControllerAdvice annotation on a class
All of the above
All of the above

What is the purpose of the @ModelAttribute annotation in Spring MVC?
To bind request parameters to method arguments
To bind model attributes to the view
To bind form data to a model object
To bind request headers to method arguments
To bind form data to a model object

What is the role of a ViewResolver in Spring MVC?
To determine the view that will be used to render the response
To format the data model for the view
To handle user input in the view
To validate the data model before rendering the view
To determine the view that will be used to render the response

What is the purpose of the @RequestMapping annotation in Spring MVC?
To map a model attribute to a specific request parameter
To map a URL to a specific controller method
To map a view to a specific model attribute
To map a specific HTTP method to a controller method
To map a URL to a specific controller method

How can you specify which HTTP methods are supported by a controller method in Spring MVC?
By using the @RequestMethod annotation
By using the @RequestMapping annotation with the method property
By using the @GetMapping, @PostMapping, @PutMapping, etannotations
All of the above
All of the above

What is the role of the DispatcherServlet in Spring MVC?
To handle all incoming HTTP requests
To delegate the processing of requests to appropriate controllers
To determine the view that will be used to render the response
To format the data model for the view
To delegate the processing of requests to appropriate controllers

How can you specify the content type of a response in Spring MVC?
By using the @ResponseBody annotation on a controller method
By using the @ResponseType annotation on a controller method
By setting the content type in the HttpServletResponse object
All of the above
By setting the content type in the HttpServletResponse object

How can you pass data from a controller to a view in Spring MVC?
By using the Model object
By using the @ModelAttribute annotation
By using the @SessionAttribute annotation
By using the @RequestAttribute annotation
By using the Model object

Submit
Retry
{"qz1-955693":"To handle user requests and return appropriate response","qz1-955694":"Filters operate at the servlet level, while interceptors operate at the controller level","qz1-955695":"All of the above","qz1-955696":"To bind form data to a model object","qz1-955697":"To determine the view that will be used to render the response","qz1-955698":"To map a URL to a specific controller method","qz1-955699":"All of the above","qz1-955700":"To delegate the processing of requests to appropriate controllers","qz1-955701":"By setting the content type in the HttpServletResponse object","qz1-955702":"By using the Model object"}

    Leave a Comment


  • captcha text