Loading

Quipoin Menu

Learn • Practice • Grow

angular / Handling Responses and Errors
mcq
Direction: Choose the correct option

Q1.

How do you handle the response from an HTTP request?
A. Using `.subscribe()` on the observable
B. Using `async/await`
C. Using callbacks
D. Using `.then()`
Direction: Choose the correct option

Q2.

How do you handle errors in HttpClient?
A. Using `error` event
B. Using `try/catch`
C. Using `onError`
D. Using the error callback in `subscribe` or `catchError` operator
Direction: Choose the correct option

Q3.

What is the `catchError` operator used for?
A. To catch HTTP errors only
B. To catch exceptions
C. To catch network errors
D. To catch errors on the observable stream and handle them
Direction: Choose the correct option

Q4.

How do you retry a failed HTTP request?
A. Using `retry` or `retryWhen` operators
B. Using `repeat`
C. Using `retryRequest`
D. Using `again` method
Direction: Choose the correct option

Q5.

What does the `finalize` operator do?
A. Closes the connection
B. Finalizes the request
C. Ends the subscription
D. Executes logic when the observable completes or errors
Direction: Choose the correct option

Q6.

What is the `HttpErrorResponse` error property?
A. Contains details about the error (status, message, etc.)
B. Contains error stack
C. Contains error code
D. Contains error text
Direction: Choose the correct option

Q7.

How do you handle different HTTP status codes?
A. Check the `error.status` property and act accordingly
B. All of the above
C. Use multiple `catchError`
D. Use `catchError` with switch case
Direction: Choose the correct option

Q8.

What is the purpose of `throwError` from RxJS?
A. To handle errors
B. To create errors
C. To create an observable that emits an error notification
D. To throw errors
Direction: Choose the correct option

Q9.

How do you access the response body in a successful response?
A. In error callback
B. In the subscribe's next callback: `data => {}`
C. In complete callback
D. In `finalize`
Direction: Choose the correct option

Q10.

What is the complete callback in subscribe used for?
A. Called when the observable completes (no more values)
B. Called on success
C. Called always
D. Called on error