Angular MCQs – Introduction to Angular

11.) What command is used to create a new Angular project using Angular CLI?

A) ng create project-name
B) ng new project-name
C) angular new project-name
D) ng start project-name

Answer: Option B

Explanation: The ng new command is used to create a new Angular project.

12.) What is Angular CLI used for?

A) Running JavaScript code
B) Managing databases
C) Creating and managing Angular projects
D) Writing CSS files

Answer: Option C

Explanation: Angular CLI (Command Line Interface) simplifies Angular project creation, configuration, and maintenance.

13.) Which decorator is used to define an Angular component?

A) @Service
B) @Directive
C) @Component
D) @Injectable

Answer: Option C

Explanation: The @Component decorator is used to define metadata for Angular components.

14.) What is a Directive in Angular?

A) A function to make API calls
B) A way to manipulate the DOM
C) A module
D) A CSS class

Answer: Option B

Explanation: Directives extend HTML functionality by modifying the DOM behavior.

15.) Which Angular directive is used for conditional rendering?

A) *ngIf
B) *ngFor
C) *ngModel
D) *ngSwitch

Answer: Option A

Explanation: *ngIf dynamically adds or removes elements based on a condition.

16.) Which of the following is NOT a valid Angular directive?

A) *ngIf
B) *ngFor
C) *ngClass
D) *ngRepeat

Answer: Option D

Explanation: *ngRepeat was used in AngularJS, but in Angular (2+), *ngFor is used for looping through lists.

17.) What is the purpose of Angular Modules (NgModule)?

A) To create services
B) To define Angular components and dependencies
C) To style an Angular application
D) To manage HTTP requests

Answer: Option B

Explanation: The @NgModule decorator is used to organize an Angular application by grouping components, services, and dependencies into modules.

18.) What is the purpose of RouterModule in Angular?

A) To manage component styles
B) To store application data
C) To handle application routing
D) To handle application routing

Answer: Option C

Explanation: The RouterModule enables navigation and route management in Angular applications.

19.) What is the default file where Angular component styles are defined?

A) styles.css
B) app.component.html
C) app.module.ts
D) app.component.css

Answer: Option D

Explanation: Angular component styles are typically defined in a separate .css file associated with the component.

20.) What is Lazy Loading in Angular?

A) A way to delay HTTP requests
B) A method to load only required modules on demand
C) A performance issue in Angular applications
D) A CSS technique for styling Angular components

Answer: Option B

Explanation: Lazy loading helps improve application performance by loading modules only when they are needed.

Leave a Reply

Your email address will not be published. Required fields are marked *