MEAN Questions Set 2
MEAN Questions Set 2
_Answer:_ Angular lifecycle hooks are methods that get called during the different
phases of a component’s lifecycle. Examples: `ngOnInit()`, `ngOnDestroy()`,
`ngAfterViewInit()`.
_Answer:_ You can create a service using the Angular CLI with `ng generate service
serviceName` and inject it into components via dependency injection.
_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.
_Answer:_ Errors are handled using `try-catch` blocks for synchronous code and
promise rejections or `async/await` with error handling for asynchronous code.
_Answer:_ `find()` is used to query the database and retrieve documents that match
the query criteria.
_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.
_Answer:_ A RESTful API adheres to the principles of REST, using HTTP methods,
stateless communication, and resource representation through URIs.
_Answer:_ File uploads can be handled in Node.js using middleware such as `multer`
to parse form data and store files on the server.
_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.
_Answer:_ Lazy loading in Angular loads feature modules only when the route
associated with that module is activated, reducing initial load time.
_Answer:_ You can debug a Node.js application using the built-in `node --inspect`
command, Chrome DevTools, or Visual Studio Code’s debugging tools.