Loading

Quipoin Menu

Learn • Practice • Grow

angular / HTTP Interceptors
mcq
Direction: Choose the correct option

Q1.

What is an HTTP interceptor in Angular?
A. A security guard
B. A caching mechanism
C. A network monitor
D. A service that intercepts and modifies HTTP requests/responses
Direction: Choose the correct option

Q2.

How do you create an interceptor?
A. Implement `HttpInterceptor` interface
B. Extend `HttpHandler`
C. Use `@Interceptor` decorator
D. Create a service with `@Injectable`
Direction: Choose the correct option

Q3.

What do interceptors return?
A. `HttpRequest`
B. `Observable<HttpEvent>`
C. `HttpHandler`
D. `HttpResponse`
Direction: Choose the correct option

Q4.

How do you register an interceptor?
A. Add it to `providers` array
B. Use `@NgModule`
C. Provide it in the `HTTP_INTERCEPTORS` multi-provider
D. Import it in the module
Direction: Choose the correct option

Q5.

What is a common use case for interceptors?
A. Form validation
B. Creating components
C. Adding authentication headers to every request
D. Routing
Direction: Choose the correct option

Q6.

Can you have multiple interceptors?
A. Only two
B. No, only one
C. Yes, they run in the order they are provided
D. Only in specific order
Direction: Choose the correct option

Q7.

What is the `HttpHandler` interface?
A. Handles requests
B. Handles HTTP
C. Represents the next interceptor in the chain or the backend
D. Handles responses
Direction: Choose the correct option

Q8.

How do you modify a request in an interceptor?
A. Use `req.update`
B. Modify the request directly
C. Clone the request: `req.clone({setHeaders: {Authorization: token}})`
D. Use `req.set`
Direction: Choose the correct option

Q9.

Can interceptors modify responses?
A. No, only requests
B. Only with `catchError`
C. Yes, by using operators like `map` on the response observable
D. Only in error cases
Direction: Choose the correct option

Q10.

How do you handle errors globally with interceptors?
A. Use `error` callback
B. Use `catchError` on the response stream
C. Use `finalize`
D. Use `throwError`