• Tutorials
  • Courses
  • Tracks

Advanced Java Quiz Day 69

Last Updated :
Discuss
Comments

Question 1

Which annotation in Spring is used to handle exceptions at the controller level?

  • @HandleError

  • @ExceptionHandler

  • @ErrorMapping

  • @ControllerError

Question 2

What is the purpose of @ControllerAdvice in Spring?

  • To configure database transactions globally

  • To apply exception handling logic across multiple controllers

  • To manage session data

  • To handle only runtime exceptions

Question 3

Which method return type is commonly used in @ExceptionHandler methods?

  • void

  • ResponseEntity<?>

  • StringBuilder

  • HttpServletRequest

Question 4

In Spring Boot, what is the default HTTP status returned for an unhandled exception?

  • 200 OK

  • 400 Bad Request

  • 404 Not Found

  • 500 Internal Server Error

Question 5

Which Spring annotation can be used in a custom exception class to specify the HTTP status code?

  • @HttpStatus

  • @ResponseStatus

  • @StatusCode

  • @StatusMapping

Question 6

Which annotation inside @ControllerAdvice specifies which exceptions a method should handle?

  • @ExceptionHandler

  • @HandleThis

  • @CatchException

  • @ErrorHandler

Question 7

For a custom exception ResourceNotFoundException, which HTTP status is most appropriate?

  • 200 OK

  • 404 Not Found

  • 403 Forbidden

  • 500 Internal Server Error

Question 8

Which Spring Boot class automatically provides JSON error responses for exceptions if no handler is defined?

  • ErrorController

  • ExceptionController

  • DefaultErrorHandler

  • ResponseEntityExceptionHandler

Question 9

What is the main advantage of global exception handling using @ControllerAdvice?

  • It increases database performance

  • It centralizes exception handling logic

  • It removes the need for logging

  • It disables default error pages

There are 9 questions to complete.

Take a part in the ongoing discussion