Loading

Quipoin Menu

Learn • Practice • Grow

angular / Async Pipe with HTTP
mcq
Direction: Choose the correct option

Q1.

What does the `async` pipe do?
A. Both A and B
B. Subscribes to an observable and returns the latest value
C. Creates observables
D. Unsubscribes automatically
Direction: Choose the correct option

Q2.

How do you use `async` pipe with an HTTP observable in a template?
A. `*ngFor='let user of users$'`
B. `{{ users$ }}`
C. `users$ | subscribe`
D. `{{ users$ | async }}`
Direction: Choose the correct option

Q3.

What is the advantage of using `async` pipe with `*ngIf`?
A. To cache data
B. To create observables
C. To unsubscribe
D. To handle loading states and errors efficiently
Direction: Choose the correct option

Q4.

What happens if you use `async` pipe multiple times on the same observable?
A. An error occurs
B. Only one subscription is shared
C. Multiple subscriptions are created (may be inefficient)
D. The pipe caches the result
Direction: Choose the correct option

Q5.

How can you avoid multiple subscriptions with `async` pipe?
A. Use the `as` syntax with `*ngIf` or `*ngFor`
B. All of the above
C. Use a single subscription
D. Use `share` operator
Direction: Choose the correct option

Q6.

What does `users$ | async as users` do?
A. Stores async result
B. Creates a new variable
C. Async as alias
D. Subscribes to users$ and assigns the emitted value to the 'users' variable
Direction: Choose the correct option

Q7.

How do you handle loading state with `async` pipe?
A. Not possible
B. Use `ngIf` only
C. Use `ngSwitch`
D. Combine with `*ngIf; else loading` using a loading template
Direction: Choose the correct option

Q8.

What happens to the subscription when the component is destroyed?
A. Error occurs
B. Memory leak occurs
C. Subscription continues
D. The `async` pipe automatically unsubscribes
Direction: Choose the correct option

Q9.

Can `async` pipe be used with promises?
A. Yes, it works with any thenable
B. Only with async
C. No, only observables
D. Only with HttpClient
Direction: Choose the correct option

Q10.

What is the recommended way to combine multiple `async` pipes?
A. Use `combineLatest`
B. Use `forkJoin`
C. Use multiple pipes
D. Use `ng-container` and `*ngIf` with `as` to create a single subscription