0% found this document useful (0 votes)
26 views

MEAN Questions Set 2

MEAN Stack Interview Questions

Uploaded by

Jeesmon shaju
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

MEAN Questions Set 2

MEAN Stack Interview Questions

Uploaded by

Jeesmon shaju
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Set 2:

1. What is the purpose of Angular's dependency injection?

_Answer:_ Dependency injection (DI) in Angular allows the injection of services or


dependencies into components, making the code modular and reusable.

2. How does Angular routing work?

_Answer:_ Angular routing allows navigation between different views or pages in a


single-page application (SPA) using the router module to map URLs to components.

3. Explain how two-way data binding works in Angular.

_Answer:_ Two-way data binding allows automatic synchronization between the


data model and the UI. `[(ngModel)]` is used to bind the data.

4. What are Angular lifecycle hooks? Name a few.

_Answer:_ Angular lifecycle hooks are methods that get called during the different
phases of a component’s lifecycle. Examples: `ngOnInit()`, `ngOnDestroy()`,
`ngAfterViewInit()`.

5. How do you create a service in Angular?

_Answer:_ You can create a service using the Angular CLI with `ng generate service
serviceName` and inject it into components via dependency injection.

6. What is an Angular Module?

_Answer:_ An Angular Module (`@NgModule`) is a class decorated with metadata


that defines a collection of components, directives, services, and pipes that can be
used together.
7. Explain what `ngIf` and `ngFor` do in Angular.

_Answer:_ `ngIf` conditionally adds or removes elements based on a Boolean


condition. `ngFor` is used to loop through an array and render its elements in the
template.

8. What are Promises in JavaScript?

_Answer:_ Promises represent the eventual completion (or failure) of an


asynchronous operation and its resulting value.

9. Explain how you would implement authentication in Node.js.

_Answer:_ Authentication can be implemented using JSON Web Tokens (JWT). The
server generates a token upon successful login, and the token is sent with each
request for validation.

10. What are the common HTTP methods used in REST APIs?

_Answer:_ GET, POST, PUT, DELETE, PATCH are commonly used HTTP methods.

11. How do you handle errors in Node.js?

_Answer:_ Errors are handled using `try-catch` blocks for synchronous code and
promise rejections or `async/await` with error handling for asynchronous code.

12. What is the purpose of middleware in Express.js?

_Answer:_ Middleware functions in Express.js are used to handle HTTP requests,


modify the request/response, and manage routing logic.

13. How does event-driven architecture work in Node.js?


_Answer:_ Node.js uses event-driven architecture where an event loop listens for
events, and callbacks are triggered when an event occurs.

14. What is the difference between `res.send()` and `res.json()` in Express?

_Answer:_ `res.send()` sends a response of any type, while `res.json()` specifically


sends a JSON response and sets the correct content type header.

15. Explain the purpose of `mongoose.Schema`.

_Answer:_ `mongoose.Schema` defines the structure of documents within a


MongoDB collection, specifying field types, validations, and default values.

16. What is MongoDB?

_Answer:_ MongoDB is a NoSQL database that stores data in flexible, JSON-like


documents, allowing for schema-less design and high scalability.

17. How do you use the `find()` method in MongoDB?

_Answer:_ `find()` is used to query the database and retrieve documents that match
the query criteria.

18. How would you implement pagination in MongoDB?

_Answer:_ Pagination in MongoDB is done using the `limit()` and `skip()` methods to
control the number of documents returned and the starting point of the result set.

19. What is CORS, and how is it handled in Node.js?

_Answer:_ CORS (Cross-Origin Resource Sharing) is a mechanism that allows


restricted resources on a web page to be requested from another domain. It is
handled in Node.js using the `cors` package.

20. What is the purpose of `res.status()` in Express.js?


_Answer:_ `res.status()` sets the HTTP status code for the response, indicating the
outcome of the request (e.g., 200 for success, 404 for not found).

21. What is a RESTful API?

_Answer:_ A RESTful API adheres to the principles of REST, using HTTP methods,
stateless communication, and resource representation through URIs.

22. How do you handle file uploads in Node.js?

_Answer:_ File uploads can be handled in Node.js using middleware such as `multer`
to parse form data and store files on the server.

23. Explain how to establish a MongoDB connection using Mongoose in Node.js.

_Answer:_ Use `mongoose.connect('mongodb://localhost:27017/dbname')` to


establish a connection to a MongoDB database from Node.js.

24. What is a schema-less database?

_Answer:_ A schema-less database, like MongoDB, does not enforce a strict data
structure, allowing flexible document storage without predefined schemas.

25. What are the differences between SQL and NoSQL databases?

_Answer:_ SQL databases use structured schemas and relations, while NoSQL
databases are schema-less, supporting unstructured or semi-structured data.

26. Explain how the aggregation pipeline works in MongoDB.


_Answer:_ The aggregation pipeline in MongoDB processes data through multiple
stages, such as filtering, grouping, and transforming, to perform complex queries.

27. How can you protect routes in an Angular application?

_Answer:_ Use `AuthGuard` in Angular to protect routes and ensure only


authenticated users can access certain pages.

28. What is Lazy Loading in Angular?

_Answer:_ Lazy loading in Angular loads feature modules only when the route
associated with that module is activated, reducing initial load time.

29. How can you debug a Node.js application?

_Answer:_ You can debug a Node.js application using the built-in `node --inspect`
command, Chrome DevTools, or Visual Studio Code’s debugging tools.

30. What is `nodemon` used for in Node.js development?

_Answer:_ `nodemon` is a utility that automatically restarts a Node.js application


when it detects file changes, speeding up the development process.

You might also like