Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
Spring Boot - REST Controllers
Identify the error in this code snippet:
return ResponseEntity.status(200).body();
Astatus() cannot accept int, must use HttpStatus enum
Bbody() requires a non-null argument
CMissing semicolon at end
DResponseEntity cannot be returned directly
Step-by-Step Solution
Solution:
  1. Step 1: Check body() method usage

    body() requires an argument for the response body content.
  2. Step 2: Confirm status() accepts int

    status(int) is allowed, but body() must have argument.
  3. Final Answer:

    body() requires a non-null argument -> Option B
  4. Quick Check:

    body() needs argument = B [OK]
Quick Trick: Always provide argument to body() method [OK]
Common Mistakes:
  • Calling body() without argument
  • Assuming status() only accepts HttpStatus enum
  • Ignoring method chaining rules

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes