Q. What is the purpose of Angular Signals introduced in Angular 16?

  • (A) To improve routing performance
  • (B) To replace RxJS Observables
  • (C) To track reactive values with fine-grained reactivity
  • (D) To cache HTTP responses
πŸ’¬ Discuss
βœ… Correct Answer: (C) To track reactive values with fine-grained reactivity
Explanation: Angular Signals provide reactive primitives that allow better change detection and reactivity.

Q. Which command is used to create a new Angular standalone component?

  • (A) ng generate component
  • (B) ng new component
  • (C) ng generate component --standalone
  • (D) ng create standalone-component
πŸ’¬ Discuss
βœ… Correct Answer: (C) ng generate component --standalone
Explanation: The `--standalone` flag creates a standalone component without needing to declare it in a module.

Q. Which operator is commonly used in Angular with Observables to unsubscribe automatically?

  • (A) subscribe()
  • (B) finalize()
  • (C) takeUntil()
  • (D) switchMap()
πŸ’¬ Discuss
βœ… Correct Answer: (C) takeUntil()
Explanation: `takeUntil` allows automatic unsubscription when a signal (e.g. destroy$) emits.

Q. How do you define a route parameter in Angular routing?

  • (A) { path: 'user:id', component: UserComponent }
  • (B) { path: 'user/:id', component: UserComponent }
  • (C) { path: 'user/id', component: UserComponent }
  • (D) { path: 'user?=id', component: UserComponent }
πŸ’¬ Discuss
βœ… Correct Answer: (B) { path: 'user/:id', component: UserComponent }
Explanation: Colon (:) syntax is used to define route parameters in Angular.

Q. What is the primary use of the Angular TestBed utility?

  • (A) Creating services
  • (B) Routing between components
  • (C) Unit testing Angular components
  • (D) Handling change detection
πŸ’¬ Discuss
βœ… Correct Answer: (C) Unit testing Angular components
Explanation: TestBed is used to configure and initialize environments for unit testing.

Q. Which lifecycle hook is triggered every time Angular checks for changes?

  • (A) ngOnInit
  • (B) ngDoCheck
  • (C) ngAfterViewInit
  • (D) ngOnDestroy
πŸ’¬ Discuss
βœ… Correct Answer: (B) ngDoCheck
Explanation: ngDoCheck is called on every change detection run.

Q. How do you access query parameters in an Angular component?

  • (A) this.route.snapshot.queryParams
  • (B) this.router.queryParams
  • (C) window.location.queryParams
  • (D) this.queryParams.get()
πŸ’¬ Discuss
βœ… Correct Answer: (A) this.route.snapshot.queryParams
Explanation: You can access query parameters using ActivatedRoute's snapshot.queryParams.

Q. Which Angular feature ensures that a module or component is loaded only when needed?

  • (A) Preloading strategy
  • (B) Eager loading
  • (C) Lazy loading
  • (D) Tree shaking
πŸ’¬ Discuss
βœ… Correct Answer: (C) Lazy loading
Explanation: Lazy loading delays loading of a module/component until it's needed.

Q. What is a structural directive in Angular?

  • (A) A directive that changes CSS styles
  • (B) A directive that changes layout by adding/removing DOM elements
  • (C) A directive that logs events
  • (D) A directive that handles animations
πŸ’¬ Discuss
βœ… Correct Answer: (B) A directive that changes layout by adding/removing DOM elements
Explanation: Structural directives like *ngIf or *ngFor modify the DOM layout.

Q. What does the `resolve` property in Angular routes do?

  • (A) Prevents unauthorized users from accessing a route
  • (B) Handles 404 errors
  • (C) Fetches data before the route is activated
  • (D) Redirects users after login
πŸ’¬ Discuss
βœ… Correct Answer: (C) Fetches data before the route is activated
Explanation: `resolve` lets you fetch required data before the route loads.