Q. What is the main purpose of ChangeDetectionStrategy.OnPush?

  • (A) Runs change detection on every event
  • (B) Improves performance by reducing change detection cycles
  • (C) Disables change detection completely
  • (D) Works only with services
πŸ’¬ Discuss
βœ… Correct Answer: (B) Improves performance by reducing change detection cycles
Explanation: OnPush runs change detection only when input references change or events occur.

Q. Which Angular lifecycle hook is called after content projection?

  • (A) ngOnInit
  • (B) ngAfterViewInit
  • (C) ngAfterContentInit
  • (D) ngDoCheck
πŸ’¬ Discuss
βœ… Correct Answer: (C) ngAfterContentInit
Explanation: ngAfterContentInit is called after projected content is initialized.

Q. What does the async pipe do?

  • (A) Subscribes and unsubscribes automatically
  • (B) Converts promises to observables
  • (C) Handles HTTP calls
  • (D) Improves routing speed
πŸ’¬ Discuss
βœ… Correct Answer: (A) Subscribes and unsubscribes automatically
Explanation: Async pipe handles subscription and unsubscription automatically.

Q. Which RxJS operator is used to cancel previous HTTP calls?

  • (A) mergeMap
  • (B) concatMap
  • (C) switchMap
  • (D) map
πŸ’¬ Discuss
βœ… Correct Answer: (C) switchMap
Explanation: switchMap cancels the previous observable when a new one is emitted.

Q. Which decorator is used to make a class injectable?

  • (A) @Component
  • (B) @NgModule
  • (C) @Injectable
  • (D) @Pipe
πŸ’¬ Discuss
βœ… Correct Answer: (C) @Injectable
Explanation: @Injectable marks a class available for dependency injection.

Q. What does ViewEncapsulation.ShadowDom do?

  • (A) Disables CSS
  • (B) Applies global styles
  • (C) Uses native Shadow DOM for style encapsulation
  • (D) Inlines styles
πŸ’¬ Discuss
βœ… Correct Answer: (C) Uses native Shadow DOM for style encapsulation
Explanation: ShadowDom uses browser's native Shadow DOM for encapsulation.

Q. Which guard prevents loading of lazy-loaded modules?

  • (A) CanActivate
  • (B) CanDeactivate
  • (C) CanLoad
  • (D) Resolve
πŸ’¬ Discuss
βœ… Correct Answer: (C) CanLoad
Explanation: CanLoad prevents lazy modules from being loaded.

Q. Which strategy allows preloading lazy-loaded modules?

  • (A) NoPreloading
  • (B) PreloadAllModules
  • (C) EagerLoading
  • (D) LoadOnDemand
πŸ’¬ Discuss
βœ… Correct Answer: (B) PreloadAllModules
Explanation: PreloadAllModules loads lazy modules in the background.

Q. What is a pure pipe?

  • (A) Always recalculates
  • (B) Executes only when input changes
  • (C) Used only for numbers
  • (D) Executes every change detection
πŸ’¬ Discuss
βœ… Correct Answer: (B) Executes only when input changes
Explanation: Pure pipes run only when their input values change.

Q. Which Angular feature helps in reducing bundle size?

  • (A) NgModules
  • (B) Lazy loading
  • (C) Two-way binding
  • (D) Event binding
πŸ’¬ Discuss
βœ… Correct Answer: (B) Lazy loading
Explanation: Lazy loading loads modules only when required.