Programming MCQs Feed

📊 Angular
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.

📊 Angular
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.

📊 Angular
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.

📊 Angular
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.

📊 Angular
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.

📊 Angular
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.

📊 Angular
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.

📊 Angular
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.

📊 Angular
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.

📊 Angular
Q. What does providedIn: 'root' do?
  • (A) Creates multiple service instances
  • (B) Provides service at component level
  • (C) Registers service as singleton at root level
  • (D) Disables DI
💬 Discuss
✅ Correct Answer: (C) Registers service as singleton at root level

Explanation: providedIn: 'root' creates a singleton service.