← Quiz: REST APIs: all 10 questions
Quiz: REST APIs · Question 7 of 10
What does @PathVariable Long id read in @GetMapping("/{id}")?
What does @PathVariable Long id read in @GetMapping("/{id}")?
- A.The {id} part of the URL, such as 7 in /api/courses/7
- B.A query parameter such as ?id=7
- C.The JSON request body
- D.An HTTP header named id
Answer & explanation
Correct answer: The {id} part of the URL, such as 7 in /api/courses/7
Path variables come from the URL path; query parameters use @RequestParam.
Can you get the rest right without peeking?
Take the timed Quiz: REST APIs quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →