Q. What is the purpose of NgRx in Angular applications?

  • (A) Routing
  • (B) Animation handling
  • (C) State management
  • (D) HTTP communication
πŸ’¬ Discuss
βœ… Correct Answer: (C) State management
Explanation: NgRx is a library for managing state in Angular using Redux-like patterns.

Q. Which NgRx feature is used to dispatch actions?

  • (A) Store
  • (B) Effect
  • (C) Reducer
  • (D) Selector
πŸ’¬ Discuss
βœ… Correct Answer: (A) Store
Explanation: The Store is used to dispatch actions and select state.

Q. What is the main role of NgRx effects?

  • (A) To handle animations
  • (B) To reduce data
  • (C) To handle side effects like API calls
  • (D) To route users to components
πŸ’¬ Discuss
βœ… Correct Answer: (C) To handle side effects like API calls
Explanation: Effects listen for dispatched actions and handle side effects like API calls.

Q. What is a selector in NgRx?

  • (A) A router directive
  • (B) A function to fetch a part of the state
  • (C) An Angular component
  • (D) A variable for storing IDs
πŸ’¬ Discuss
βœ… Correct Answer: (B) A function to fetch a part of the state
Explanation: Selectors are used to query specific pieces of the NgRx store state.

Q. Which decorator is used to define input properties in Angular?

  • (A) @ViewChild
  • (B) @Input
  • (C) @Output
  • (D) @Injectable
πŸ’¬ Discuss
βœ… Correct Answer: (B) @Input
Explanation: @Input is used to pass data from parent to child components.

Q. How do you emit an event from a child to parent component?

  • (A) Using @Input
  • (B) Using @ViewChild
  • (C) Using @Output and EventEmitter
  • (D) Using @Injectable service
πŸ’¬ Discuss
βœ… Correct Answer: (C) Using @Output and EventEmitter
Explanation: @Output along with EventEmitter allows child components to emit events to parent components.

Q. Which HTTP method is used in Angular to fetch data from a server?

  • (A) post()
  • (B) put()
  • (C) get()
  • (D) delete()
πŸ’¬ Discuss
βœ… Correct Answer: (C) get()
Explanation: The `get()` method of HttpClient is used to fetch data from an API.

Q. What is Angular Universal?

  • (A) Mobile app framework
  • (B) CLI tool
  • (C) Server-side rendering platform
  • (D) Package manager
πŸ’¬ Discuss
βœ… Correct Answer: (C) Server-side rendering platform
Explanation: Angular Universal enables server-side rendering for Angular applications.

Q. Which mechanism helps secure Angular applications against XSS?

  • (A) DomSanitizer
  • (B) HttpInterceptor
  • (C) NgModules
  • (D) Lazy loading
πŸ’¬ Discuss
βœ… Correct Answer: (A) DomSanitizer
Explanation: DomSanitizer ensures unsafe values are sanitized before rendering in the DOM.

Q. What is the purpose of HttpInterceptor in Angular?

  • (A) Add interceptors for routing
  • (B) Handle change detection
  • (C) Modify HTTP requests and responses
  • (D) Create new observables
πŸ’¬ Discuss
βœ… Correct Answer: (C) Modify HTTP requests and responses
Explanation: HttpInterceptors allow interception and transformation of HTTP requests/responses globally.