Q. What is a key benefit of using Angular's OnPush change detection strategy?

  • (A) Eager loading all components
  • (B) Improved performance by reducing change detection
  • (C) Adding extra watchers
  • (D) Automatically unsubscribing Observables
πŸ’¬ Discuss
βœ… Correct Answer: (B) Improved performance by reducing change detection
Explanation: OnPush limits change detection to only when input references change, enhancing performance.

Q. How can services be shared across all modules in Angular?

  • (A) Add them in any component
  • (B) Provide them in a child component
  • (C) Provide them in root injector using providedIn: 'root'
  • (D) Declare them in component metadata
πŸ’¬ Discuss
βœ… Correct Answer: (C) Provide them in root injector using providedIn: 'root'
Explanation: Services with `providedIn: 'root'` are singleton and shared across the app.

Q. What does the async pipe automatically do in templates?

  • (A) Refresh DOM manually
  • (B) Subscribe and unsubscribe from Observables
  • (C) Reload entire component
  • (D) Prevent memory leaks
πŸ’¬ Discuss
βœ… Correct Answer: (B) Subscribe and unsubscribe from Observables
Explanation: Async pipe manages subscription lifecycle automatically in templates.

Q. Which file contains metadata for the root Angular module?

  • (A) index.html
  • (B) main.ts
  • (C) app.module.ts
  • (D) angular.json
πŸ’¬ Discuss
βœ… Correct Answer: (C) app.module.ts
Explanation: app.module.ts declares and bootstraps the root module.

Q. Which method is used in Angular to clone an Observable?

  • (A) shareReplay()
  • (B) pipe()
  • (C) clone()
  • (D) repeat()
πŸ’¬ Discuss
βœ… Correct Answer: (A) shareReplay()
Explanation: shareReplay allows multicasting of the same Observable without multiple subscriptions.

Q. What is the use of ChangeDetectorRef in Angular?

  • (A) Creating dynamic components
  • (B) Manual triggering of change detection
  • (C) Routing between views
  • (D) Event handling
πŸ’¬ Discuss
βœ… Correct Answer: (B) Manual triggering of change detection
Explanation: ChangeDetectorRef provides APIs to manually trigger or detach change detection.

Q. How can you track identity of items in ngFor for performance?

  • (A) Using index
  • (B) Using key
  • (C) Using trackBy function
  • (D) Using map operator
πŸ’¬ Discuss
βœ… Correct Answer: (C) Using trackBy function
Explanation: trackBy improves performance by identifying items uniquely during changes.

Q. Which strategy reduces Angular bundle size?

  • (A) Using ng serve
  • (B) Importing all modules at once
  • (C) Lazy loading modules
  • (D) Using inline templates
πŸ’¬ Discuss
βœ… Correct Answer: (C) Lazy loading modules
Explanation: Lazy loading defers module loading, reducing initial bundle size.

Q. What happens if you forget to unsubscribe from a subscription?

  • (A) Component runs faster
  • (B) No effect
  • (C) Memory leaks may occur
  • (D) Template errors
πŸ’¬ Discuss
βœ… Correct Answer: (C) Memory leaks may occur
Explanation: Not unsubscribing from subscriptions can cause memory leaks.

Q. Which Angular compiler replaced ViewEngine?

  • (A) Ivy
  • (B) NGCC
  • (C) RxJS
  • (D) Zone.js
πŸ’¬ Discuss
βœ… Correct Answer: (A) Ivy
Explanation: Ivy is the newer rendering and compilation engine in Angular for better performance.