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.

Q. Which lifecycle hook is used to clean up subscriptions?

  • (A) ngOnInit
  • (B) ngAfterViewInit
  • (C) ngOnDestroy
  • (D) ngDoCheck
πŸ’¬ Discuss
βœ… Correct Answer: (C) ngOnDestroy
Explanation: ngOnDestroy is used to clean up resources like subscriptions.

Q. Which directive is used to dynamically load templates?

  • (A) ngTemplateOutlet
  • (B) ngContent
  • (C) ngSwitch
  • (D) ngIf
πŸ’¬ Discuss
βœ… Correct Answer: (A) ngTemplateOutlet
Explanation: ngTemplateOutlet dynamically renders templates.

Q. What is the main benefit of standalone components?

  • (A) Require more modules
  • (B) Reduce boilerplate code
  • (C) Disable routing
  • (D) Increase app size
πŸ’¬ Discuss
βœ… Correct Answer: (B) Reduce boilerplate code
Explanation: Standalone components reduce dependency on NgModules.

Q. Which operator is best for sequential HTTP calls?

  • (A) mergeMap
  • (B) switchMap
  • (C) concatMap
  • (D) forkJoin
πŸ’¬ Discuss
βœ… Correct Answer: (C) concatMap
Explanation: concatMap ensures sequential execution.

Q. What does trackBy function improve in *ngFor?

  • (A) Security
  • (B) Rendering performance
  • (C) Routing
  • (D) Form validation
πŸ’¬ Discuss
βœ… Correct Answer: (B) Rendering performance
Explanation: trackBy helps Angular track items efficiently.

Q. Which Angular feature replaces constructor injection in functional APIs?

  • (A) inject()
  • (B) useFactory
  • (C) providers array
  • (D) useClass
πŸ’¬ Discuss
βœ… Correct Answer: (A) inject()
Explanation: inject() function allows DI without constructor.

Q. What is the purpose of HttpInterceptor?

  • (A) Routing control
  • (B) Global request/response handling
  • (C) State management
  • (D) Template rendering
πŸ’¬ Discuss
βœ… Correct Answer: (B) Global request/response handling
Explanation: HttpInterceptor intercepts HTTP requests and responses globally.

Q. Which Angular feature allows signals-based reactivity?

  • (A) RxJS Subjects
  • (B) Zone.js
  • (C) Angular Signals
  • (D) ChangeDetectorRef
πŸ’¬ Discuss
βœ… Correct Answer: (C) Angular Signals
Explanation: Angular Signals provide fine-grained reactivity without relying on RxJS.

Q. What does ChangeDetectorRef.detach() do?

  • (A) Destroys the component
  • (B) Stops change detection for the component
  • (C) Refreshes the view
  • (D) Triggers routing
πŸ’¬ Discuss
βœ… Correct Answer: (B) Stops change detection for the component
Explanation: detach() removes the component from change detection tree.