0
0
Spring Bootframework~10 mins

ResponseEntity for full response control in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to return a ResponseEntity with status 200 OK.

Spring Boot
return ResponseEntity.[1]().body("Success");
Drag options to blanks, or click blank then click option'
Aok
Bstatus
Cbuild
Dcreate
Attempts:
3 left
💡 Hint
Common Mistakes
Using methods like status() without specifying status code.
Trying to use build() without setting status.
2fill in blank
medium

Complete the code to set the HTTP status to 404 NOT FOUND.

Spring Boot
return ResponseEntity.status(HttpStatus.[1]).body("Not Found");
Drag options to blanks, or click blank then click option'
AOK
BCREATED
CBAD_REQUEST
DNOT_FOUND
Attempts:
3 left
💡 Hint
Common Mistakes
Using OK or CREATED which are 200 and 201 statuses.
Using BAD_REQUEST which is 400.
3fill in blank
hard

Fix the error in setting a custom header in ResponseEntity.

Spring Boot
return ResponseEntity.ok().header("[1]", "application/json").body(data);
Drag options to blanks, or click blank then click option'
AAccept
BContent-Type
Ccontent-type
DAuthorization
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'content-type' which may cause confusion.
Using unrelated headers like Accept or Authorization.
4fill in blank
hard

Fill both blanks to create a ResponseEntity with status 201 CREATED and a Location header.

Spring Boot
return ResponseEntity.status(HttpStatus.[1]).header("[2]", "/items/123").build();
Drag options to blanks, or click blank then click option'
ACREATED
BLocation
Ccontent-type
Dok
Attempts:
3 left
💡 Hint
Common Mistakes
Using ok() instead of CREATED.
Using content-type header instead of Location.
5fill in blank
hard

Fill all three blanks to return a ResponseEntity with status 204 NO CONTENT, a custom header, and no body.

Spring Boot
return ResponseEntity.[1]().header("[2]", "no-cache").[3]();
Drag options to blanks, or click blank then click option'
AnoContent
BCache-Control
Cbuild
Dbody
Attempts:
3 left
💡 Hint
Common Mistakes
Using body() which requires a body for 204 status.
Using wrong header names.