Express.js Movie API Quiz Quiz

  1. Question 1

    What HTTP method is typically used to add a new movie to the favorite movies list in a RESTful API?

    1. A) GET
    2. B) POST
    3. C) PUT
    4. D) DELETE
    5. E) PATCH
  2. Question 2

    Which Express.js middleware function is commonly used to parse incoming request bodies in JSON format?

    1. A) express.static()
    2. B) express.json()
    3. C) express.urlencoded()
    4. D) express.cookieSession()
    5. E) express.query()
  3. Question 3

    If your Express.js server responds with a status code of 200, what does this generally indicate?

    1. A) Server Error
    2. B) Resource Not Found
    3. C) Success
    4. D) Request Timeout
    5. E) Forbidden Access
  4. Question 4

    What is the purpose of `res.status(404).send('Movie not found')` in an Express.js route handler for deleting a movie?

    1. A) To return a successful deletion message
    2. B) To indicate the server is overloaded
    3. C) To send a generic error message
    4. D) To indicate that the movie to be deleted does not exist
    5. E) To redirect the user to another page
  5. Question 5

    In an Express.js route, how do you typically access the parameters passed in the URL (e.g., `/movies/:id`)?

    1. A) req.body
    2. B) req.query
    3. C) req.params
    4. D) req.headers
    5. E) req.cookies
  6. Question 6

    Which of the following is the correct way to start an Express.js server listening on port 3000?

    1. A) server.listen(3000)
    2. B) app.start(3000)
    3. C) app.run(3000)
    4. D) app.listen(3000)
    5. E) listen.app(3000)
  7. Question 7

    What HTTP method is most suitable for retrieving a list of all favorite movies in your API?

    1. A) POST
    2. B) PUT
    3. C) DELETE
    4. D) GET
    5. E) PATCH
  8. Question 8

    Which of the following statements best describes the 'in-memory' data storage approach for the movie list?

    1. A) Data is stored in a relational database.
    2. B) Data is stored in a NoSQL database.
    3. C) Data is stored in the server's RAM and lost when the server restarts.
    4. D) Data is persistently stored in a file on the server.
    5. E) Data is stored on a cloud storage service.
  9. Question 9

    Consider this code: `app.delete('/movies/:id', (req, res) =u003E { // deletion logic }).` What might be a good way to handle an invalid movie ID in this code?

    1. A) Ignore it.
    2. B) Always return a 200 OK.
    3. C) Send an email to the system administrator.
    4. D) Respond with a 404 Not Found status code.
    5. E) Crash the server.
  10. Question 10

    Assuming you have a `movies` array storing movie objects, how would you typically send the entire array back to the client as a JSON response using Express.js?

    1. A) res.send(movies)
    2. B) res.json(movies)
    3. C) res.render(movies)
    4. D) res.sendFile(movies)
    5. E) res.redirect(movies)