Q. Which Angular feature allows form fields to be added or removed dynamically?

  • (A) FormControl
  • (B) FormGroup
  • (C) FormArray
  • (D) FormBuilder
πŸ’¬ Discuss
βœ… Correct Answer: (C) FormArray
Explanation: FormArray is used to manage a dynamic list of form controls.

Q. Which lifecycle hook is called after the component’s view has been fully initialized?

  • (A) ngAfterViewInit
  • (B) ngAfterContentInit
  • (C) ngOnInit
  • (D) ngDoCheck
πŸ’¬ Discuss
βœ… Correct Answer: (A) ngAfterViewInit
Explanation: ngAfterViewInit is called once the component's view is fully initialized.

Q. Which Angular version introduced Standalone Components?

  • (A) Angular 10
  • (B) Angular 13
  • (C) Angular 14
  • (D) Angular 15
πŸ’¬ Discuss
βœ… Correct Answer: (C) Angular 14
Explanation: Standalone components were introduced in Angular 14.

Q. What is the default scope of Angular services provided in a component?

  • (A) Application-wide
  • (B) Module-wide
  • (C) Component-only
  • (D) Global
πŸ’¬ Discuss
βœ… Correct Answer: (C) Component-only
Explanation: If provided in a component, the service is scoped to that component and its children.

Q. What is the purpose of 'providedIn: root' in a service?

  • (A) To limit the service to a module
  • (B) To make the service available application-wide
  • (C) To disable service injection
  • (D) To provide service only in root component
πŸ’¬ Discuss
βœ… Correct Answer: (B) To make the service available application-wide
Explanation: ‘providedIn: root’ registers the service in the root injector.

Q. How do you bind a CSS class conditionally in Angular?

  • (A) [class.active]='isActive'
  • (B) class='isActive ? active : inactive'
  • (C) [active]='isActive'
  • (D) *ngClass='isActive'
πŸ’¬ Discuss
βœ… Correct Answer: (A) [class.active]='isActive'
Explanation: This syntax binds the `active` class based on the boolean value of `isActive`.

Q. What is the main purpose of ChangeDetectorRef in Angular?

  • (A) To inject services
  • (B) To detect route changes
  • (C) To trigger manual change detection
  • (D) To initialize a form
πŸ’¬ Discuss
βœ… Correct Answer: (C) To trigger manual change detection
Explanation: ChangeDetectorRef allows you to trigger change detection manually.

Q. What happens when a component is destroyed in Angular?

  • (A) View is hidden but logic continues
  • (B) ngOnDestroy is called and subscriptions should be cleaned up
  • (C) Nothing happens by default
  • (D) Only the DOM is cleared
πŸ’¬ Discuss
βœ… Correct Answer: (B) ngOnDestroy is called and subscriptions should be cleaned up
Explanation: ngOnDestroy is the hook where cleanup tasks like unsubscribing are done.

Q. How can you prevent memory leaks in Angular when using Observables?

  • (A) Using setInterval
  • (B) Using HttpClient
  • (C) Unsubscribing in ngOnDestroy
  • (D) Calling next() manually
πŸ’¬ Discuss
βœ… Correct Answer: (C) Unsubscribing in ngOnDestroy
Explanation: Always unsubscribe from Observables to avoid memory leaks.

Q. Which decorator is used to pass data from parent to child component?

  • (A) @Inject
  • (B) @Input
  • (C) @Output
  • (D) @HostListener
πŸ’¬ Discuss
βœ… Correct Answer: (B) @Input
Explanation: @Input is used to receive data from a parent component.