Q1
Q1 What is Node.js primarily used for?
To create client-side interfaces
To act as a DBMS
To build server-side applications
To enhance CSS
Q2
Q2 Which engine powers Node.js?
V8
SpiderMonkey
JavaScriptCore
Chakra
Q3
Q3 Node.js is designed to handle which type of operations efficiently?
Synchronous
Asynchronous
Parallel
Serial
Q4
Q4 Which programming language is Node.js based on?
Python
Java
JavaScript
Ruby
Q5
Q5 What type of architecture does Node.js follow?
Blocking I/O
Non-blocking I/O
Procedural
Functional
Q6
Q6 Which of the following is a key feature of Node.js?
Synchronous execution
Single-threaded
Multi-threaded
Distributed
Q7
Q7 Which protocol is primarily used in Node.js for communication?
FTP
HTTP
SMTP
SNMP
Q8
Q8 What is the main advantage of using Node.js for web applications?
High CPU usage
Low memory usage
Non-blocking I/O
Static typing
Q9
Q9 Which method is used to import modules in Node.js?
require()
import()
include()
module()
Q10
Q10 What is a core module in Node.js?
A user-defined module
A built-in module
A plugin
An external library
Q11
Q11 Which of the following is a core module in Node.js?
fs
express
mongoose
socket.io
Q12
Q12 Which object is used to manage modules in Node.js?
global
module
process
exports
Q13
Q13 How can you export multiple functions from a module?
module.exports
exports
global
process
Q14
Q14 Which of the following is true about the 'require' function?
It blocks the event loop
It is asynchronous
It is non-blocking
It can load JSON files
Q15
Q15 How do you import the 'http' module in Node.js?
const http = require('http');
import http from 'http';
include http
http = require('http');
Q16
Q16 What is the output of
console.log(module.exports === exports);
true
false
undefined
null
Q17
Q17 How do you make a function available outside a module?
exports.functionName = function(){};
module.exports = function(){};
global.functionName = function(){};
process.functionName = function(){};
Q18
Q18 What should you do if a module is not found?
Reinstall Node.js
Check module spelling
Use a different IDE
Update npm
Q19
Q19 An application crashes with "Error: Cannot find module".
What should be checked?
Node version
Module installation
Network connection
Disk space
Q20
Q20 Which method reads the content of a file in Node.js?
fs.readFile
fs.open
fs.read
fs.write
Q21
Q21 Which method writes data to a file in Node.js?
fs.readFile
fs.writeFile
fs.open
fs.appendFile
Q22
Q22 What does the fs.unlink method do in Node.js?
Reads a file
Writes to a file
Deletes a file
Renames a file
Q23
Q23 Which method is used to open a file in Node.js?
fs.readFile
fs.open
fs.write
fs.unlink
Q24
Q24 How can you read the content of a directory in Node.js?
fs.readDir
fs.readDirectory
fs.readdir
fs.read
Q25
Q25 Which method is used to append data to a file in Node.js?
fs.appendFile
fs.writeFile
fs.addData
fs.insert
Q26
Q26 How do you read a file named 'example.txt' in Node.js?
fs.readFile('example.txt', callback)
fs.open('example.txt', callback)
fs.read('example.txt', callback)
fs.readFile('example.txt')
Q27
Q27 What is the output of fs.readFileSync('example.txt')?
A promise
A buffer
An error
A string
Q28
Q28 How do you check if a file exists in Node.js?
fs.existsSync('example.txt')
fs.checkFile('example.txt')
fs.exists('example.txt')
fs.fileExists('example.txt')
Q29
Q29 What should you do if fs.readFile returns an error?
Retry reading the file
Check the file path
Change file permissions
Reboot the system
Q30
Q30 How can you handle errors when writing to a file in Node.js?
Use a try-catch block
Ignore errors
Reopen the file
Restart Node.js