Question 1
What HTTP method is typically used to add a new movie to the favorite movies list in a RESTful API?
- A) GET
- B) POST
- C) PUT
- D) DELETE
- E) PATCH
Question 2
Which Express.js middleware function is commonly used to parse incoming request bodies in JSON format?
- A) express.static()
- B) express.json()
- C) express.urlencoded()
- D) express.cookieSession()
- E) express.query()
Question 3
If your Express.js server responds with a status code of 200, what does this generally indicate?
- A) Server Error
- B) Resource Not Found
- C) Success
- D) Request Timeout
- E) Forbidden Access
Question 4
What is the purpose of `res.status(404).send('Movie not found')` in an Express.js route handler for deleting a movie?
- A) To return a successful deletion message
- B) To indicate the server is overloaded
- C) To send a generic error message
- D) To indicate that the movie to be deleted does not exist
- E) To redirect the user to another page
Question 5
In an Express.js route, how do you typically access the parameters passed in the URL (e.g., `/movies/:id`)?
- A) req.body
- B) req.query
- C) req.params
- D) req.headers
- E) req.cookies
Question 6
Which of the following is the correct way to start an Express.js server listening on port 3000?
- A) server.listen(3000)
- B) app.start(3000)
- C) app.run(3000)
- D) app.listen(3000)
- E) listen.app(3000)
Question 7
What HTTP method is most suitable for retrieving a list of all favorite movies in your API?
- A) POST
- B) PUT
- C) DELETE
- D) GET
- E) PATCH
Question 8
Which of the following statements best describes the 'in-memory' data storage approach for the movie list?
- A) Data is stored in a relational database.
- B) Data is stored in a NoSQL database.
- C) Data is stored in the server's RAM and lost when the server restarts.
- D) Data is persistently stored in a file on the server.
- E) Data is stored on a cloud storage service.
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?
- A) Ignore it.
- B) Always return a 200 OK.
- C) Send an email to the system administrator.
- D) Respond with a 404 Not Found status code.
- E) Crash the server.
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?
- A) res.send(movies)
- B) res.json(movies)
- C) res.render(movies)
- D) res.sendFile(movies)
- E) res.redirect(movies)