- the call stack
- the event loop
- the poll phase
- the events queue
- webpack
- crypto
- request
- chalk
- allocUnsafe
- concat
- from
- alloc
- ftp
- events
- dgram
- http2
Q5. Which fs module method can be used to read the content of a file without buffering it in memory?
- read
- readFile
- createReadStream
- readFileSync
Explanation:
From official docs: https://nodejs.org/api/fs.html#fs_dir_read To minimize memory costs, when possible prefer streaming via fs.createReadStream().
Q6. Which of the following DNS module methods uses the underlying OS facilities and does not necessarily perform any network communication?
- lookup
- resolve
- resolve4
- reverse
- util.types.isDate(value)
- assert.isDate(value)
- console.isDate(value)
- util.date(value)
- no, there are no modules supporting it yet
- yes, with the https or http2 modules
- yes, through the path module
- yes, with the http module
Q9. What is the Api that is designed to insulate Addons from changes in the underlying JavaScript engine?
- A-API
- Z-API
- N-API
- X-API
- --dev-tools
- --inspect
- --chrome
- --debug
- node -p "process.cpus"
- node -p "util.cpus().size"
- node -p "process.os.cpus"
- node -p "os.cpus().length"
- exit
- test
- time
- global.cache
- module.cache
- process.cache
- require.cache
- node index.js --trace-warnings
- node --no-warnings
- node -trace-warnings
- node index.js --no-warnings
- new Promise(child_process.exec())
- util.promisify(child_process.exec())
- util.promisify(child_process.exec)
- new Promise(child_process.exec)
- .brake
- .history
- .editor
- .save
require('child_process').fork('script.js');
- The forked process shares the event loop with the parent process
- A new VM instance is created and the two VM instances will be shared between the forked process and the parent process.
- The forked process will have its own VM instance.
- The forked process shares the same VM thread with the parent process.
Q18. If EventEmitter is in scope, which of the following lines of code will have an event emitter emitting a change event?
- EventEmitter.emit('change');
- EventEmitter.new().emit('change');
- (new EventEmitter()).emit('change');
- new EventEmitter('change');
Explanation:
Because the EventEmitter is already in scope. No need to create new one.
- process.uptime
- process.stdout
- process
- Buffer
Explanation:
process.stdout is Buffer type.
- __pathname
- __location
- __flder
- __filename
21. If the child_process module methods are in scope, what is a current way to execute the command ps -ef using a child process?
- spawn("ps -ef")
- exec("ps -ef")
- exec("ps", "-ef")
- fork("ps -ef")
- stack
- trace
- debug
Q23.When you run JavaScript in a Node.js application, which of the following elements in a Node.js stack actually executes that JavaScript?
- the libuv library
- the c-ares library
- the VM (like VS or Chakra)
- the repl module
const http = require('http');
const hostname = '127.0.0.1'; const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200; res.setHeader("Content-Type", "text/plain"); res.end("Hello World\n");
});
server.listen(port, hostname, () => { console.log(`server running at http://${hostname}:${port}/`); });
- server running at http://localhost:3000/
- server running at port 3000
- server running at http://localhost:4000/
- server running at http://127.0.0.1:3000/
- to provide utilities to play with file and directory paths
- to provide utilities to add and remove files
- It is a retiring module.
- to provide utilities to test files
- server. start
- server.activate
- server.listen
- server. run
const fs = require('fs'); const os = require('os');
const system = os.platform(); const user = os.userInfo().username;
fs.appendFile('hello.txt', `Hello ${user} on ${system}`, (err) => { if (err) throw err; console.log('The data was appended to file!');}
);
- creates a text file hello.txt and appends customized text
- creates an image file
- console logs system information
- creates a file named data and append numbers
- nodemon start
- start index.js
- node index.js
- node start
- to provide methods to work with requests and responses
- to provide methods to work with files
- to provide methods to work with databases
- to find new file systems
- It is the current unstable version and is to be avoided.
- It is the version that will be retired soon.
- It is the version with the latest features.
- It is the safest version for long-term support.
- process. stdinfo
- process. stdin
- process. stdout
- process. stderr
Q32. You have a script.js file with the single line of code shown here. What will be the output of executing script.js with the node command?
console.log(arguments);
- ReferenceError: arguments is not defined
- an empty string
- undefined
- an object representing an array that has five elements
- start
- on
- once
- off
Q34. Which special object is an instance of EventEmitter?Which special object is an instance of null?
- process
- Buffer
- root
- require
Q35. What is the command to get a list of available commands for Node.js?What is the command to get a list of available commands for Node.js?
- node index.js -x
- node -v
- node -h
- node index.js -h
Q36. When a request event is received in the HTTP module, what is the type of the first argument passed to that event, usually named req?
- http.IncomingMessage
- http.ServerRequest
- http.ClientRequest
- http.ServerResponse
- exports, **filename, **dirname
- exports, process, require, module, **filename, **dirname
- exports, module, **filename, **dirname
- exports, require, module, **filename, **dirname
- V8
- c-ares
- libuv
- events
- a C++ file that can have a .node extension and that Node will be able to execute directly.
- a C++ Addon file that is built with node-gyp
- a JSON file that can have a .node extension as well as the .json extension
- a JavaScript file that can have a .node extension as well as the .js extension
- only objects.
- only functions
- only variables and arrays
- functions, objects, arrays, or anything you assign to the module
- os
- util
- cluster
- net
- SSL
- hash
- crypto
- TLS
- const { readFile } = require(fs).promises
- const { readFile } = require(fs)
- const { readFilePromises: readFile } = require(fs)
- const { readFile } = require(promises)
Q44. According to the rules of semantic versioning, what does a release incrementing the third number in an npm version string communicate to users about the release changes?
- Changes are not backwards compatible.
- Changes might not be backward compatible and might break existing code.
- Changes are just bug fixes and no new features were added.
- Changes will add new functionality but will not break any existing code.
- run, examine, put, loop
- read, eval, print, loop
- run, edit, print, loop
- read, extend, print, loop
- .gyprc
- binding.gyp
- gyp.json
- package.gyp
- chai
- jest
- assert
- mocha