Learn Node Js MCQs
Prepare Node Js MCQs (Multiple choice Questions) for exam and job interviews.
How do you handle uncaught exceptions in Node.js?
1) By using `process.on('uncaughtException', handler)`
2) By using `try/catch` blocks
3) By using middleware
4) By ignoring them
Answer : Option 1
What is the purpose of the `util.promisify()` function?
1) To convert callback-based functions into Promise-based functions
2) To handle asynchronous code
3) To manage file systems
4) To parse URLs
Answer : Option 1
How do you use the `querystring` module in Node.js?
1) To parse and format URL query strings
2) To handle HTTP requests
3) To work with file systems
4) To manage streams
Answer : Option 1
What is the role of the `dns` module in Node.js?
1) To perform DNS lookups and resolve domain names
2) To handle HTTP requests
3) To manage file systems
4) To work with streams
Answer : Option 1
How do you create a secure HTTP server in Node.js?
1) By using the `https` module with SSL/TLS certificates
2) By using the `http` module
3) By using the `express` module
4) By using the `tls` module
Answer : Option 1
What does the `os.arch()` method return?
1) The system architecture
2) The operating system platform
3) The CPU model
4) The system memory
Answer : Option 1
How do you use the `assert` module in Node.js?
1) To perform assertions in tests and code
2) To handle HTTP requests
3) To manage file systems
4) To parse URLs
Answer : Option 1
What is the purpose of the `console.trace()` method?
1) To print a stack trace of the execution path
2) To log information
3) To manage file systems
4) To handle HTTP requests
Answer : Option 1
How do you manage multiple Node.js versions on your system?
1) By using tools like `nvm` (Node Version Manager)
2) By using `n` module
3) By using `node` command with flags
4) By installing multiple Node.js instances manually
Answer : Option 1
What is the purpose of the `console.dir()` method?
1) To display an interactive list of object properties
2) To log information
3) To handle HTTP requests
4) To manage file systems
Answer : Option 1