Angular MCQs – Angular Project Structure and Fundamentals

Understanding the Angular project structure and its core fundamentals is essential for building scalable and maintainable applications. The structure consists of modules, components, services, and configuration files that define how an Angular application functions.

This set of top multiple-choice questions covers fundamental concepts related to Angular project structure, essential files, and CLI commands. These questions are useful for developers preparing for Angular interviews, certification exams, or simply gaining a strong foundation in Angular development.

1.) What is the main file responsible for bootstrapping an Angular application?

A) index.html
B) main.ts
C) app.module.ts
D) angular.json

Answer: Option B

Explanation: The main.ts file bootstraps the root module (AppModule) to start the Angular application.

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

A) ng create project-name
B) ng generate project
C) ng new project-name
D) npm install angular

Answer: Option C

Explanation: The ng new project-name command creates a new Angular project with a predefined folder structure.

3.) What is the default root module in an Angular application?

A) angular.json
B) app.module.ts
C) main.ts
D) app.component.ts

Answer: Option B

Explanation: The root module (AppModule) is defined in app.module.ts and serves as the main entry point for Angular applications.

4.) What is the purpose of the angular.json file?

A) It contains project configuration settings
B) It manages backend API calls
C) It defines project dependencies
D) It is responsible for component styling

Answer: Option A

Explanation: The angular.json file defines global configuration settings for an Angular project, such as build options and assets.

5.) What is the purpose of the index.html file in an Angular project?

A) It is responsible for routing
B) It defines TypeScript configurations
C) It defines TypeScript configurations
D) It acts as the main template for the application

Answer: Option D

Explanation: The index.html file contains the selector, which is replaced by the root component during runtime.

6.) What does the ng serve command do?

A) Starts a development server and serves the application
B) Creates a new Angular component
C) Builds the Angular project
D) Installs project dependencies

Answer: Option A

Explanation: ng serve compiles and runs the application in development mode using a local server.

7.) Which file is responsible for defining dependencies and scripts in an Angular project?

A) angular.json
B) package.json
C) index.html
D) main.ts

Answer: Option B

Explanation: The package.json file lists dependencies and scripts required to run, build, and test the Angular project.

8.) What is a component in Angular?

A) A UI element that controls a part of the page
B) A built-in Angular directive
C) A service that manages API calls
D) A function that fetches data from the server

Answer: Option A

Explanation: Components are the building blocks of an Angular application, defining the UI and logic for different parts of the app.

9.) What are the three main parts of an Angular component?

A) Service, Module, Component
B) Template, Class, Styles
C) Module, Directive, Pipe
D) HTML, CSS, JavaScript

Answer: Option B

Explanation: An Angular component consists of a template (HTML), a class (TypeScript logic), and styles (CSS/SCSS).

10.) What command is used to generate a new component in Angular?

A) ng create component-name
B) ng add component component-name
C) ng generate component component-name
D) ng new component component-name

Answer: Option C

Explanation: The ng generate component command creates a new Angular component with the necessary files.

Leave a Reply

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