🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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}")?

  1. A.The {id} part of the URL, such as 7 in /api/courses/7
  2. B.A query parameter such as ?id=7
  3. C.The JSON request body
  4. 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 →