Learn Node Js MCQs

Prepare Node Js MCQs (Multiple choice Questions) for exam and job interviews.

What is the purpose of `process.stdin`?

1) To access the standard input stream

2) To access the standard output stream

3) To access the current working directory

4) To access environment variables

Answer : Option 1

How do you create a secure HTTPS server in Node.js?

1) Using `https.createServer()`

2) Using `http.createServer()`

3) Using `tls.createServer()`

4) Using `net.createServer()`

Answer : Option 1

What does `process.env.NODE_ENV` typically represent?

1) The environment in which the Node.js application is running

2) The version of Node.js installed

3) The current working directory

4) The hostname of the system

Answer : Option 1

How do you write data to a writable stream?

1) Using `.write()` method

2) Using `.read()` method

3) Using `.end()` method

4) Using `.pipe()` method

Answer : Option 1

What is the purpose of `util.inherits()`?

1) To inherit the prototype methods of one constructor into another

2) To create a new EventEmitter

3) To create a new buffer

4) To create a writable stream

Answer : Option 1

How do you get the current working directory in Node.js?

1) Using `process.cwd()`

2) Using `process.env`

3) Using `process.chdir()`

4) Using `process.exit()`

Answer : Option 1

What is the purpose of the `dns.lookup()` method?

1) To resolve a domain name to an IP address

2) To resolve an IP address to a domain name

3) To check the availability of a domain

4) To manage DNS records

Answer : Option 1

How do you create a Buffer of a specified size?

1) Using `Buffer.alloc()`

2) Using `Buffer.concat()`

3) Using `Buffer.compare()`

4) Using `Buffer.from()`

Answer : Option 1

What does the `os.networkInterfaces()` method return?

1) An object containing the network interfaces of the system

2) The system’s hostname

3) The system’s architecture

4) The system’s total memory

Answer : Option 1

How do you make a DNS query in Node.js?

1) Using the `dns.resolve()` method

2) Using the `http.request()` method

3) Using the `fs.readFile()` method

4) Using the `net.connect()` method

Answer : Option 1