1. Which of the following will synchronously check if a file/directory exists?
Answers:
• fs.exists()
• fs.existsSync()
• fs.checkFileSync()
• fs.checkDirSync()
• fs.existsSync()
• fs.checkFileSync()
• fs.checkDirSync()
2. Which of the following console commands will update all installed global packages to the latest available versions?
Answers:
• npm upgrade –g
• npm install –uga
• npm update –g
• npm version —install-latest
• npm install –uga
• npm update –g
• npm version —install-latest
3. What does process.argv[1] contain?
Answers:
• node
• The file path of the JavaScript file.
• The first command line argument.
• The second command line argument.
• The file path of the JavaScript file.
• The first command line argument.
• The second command line argument.
4. Which of the following command-line arguments to «npm install» will allow an NPM package’s binaries to be run outside the project folder?
Answers:
• –g
• –global
• –l
• –link
• –global
• –l
• –link
5. Which of the following can be used to access the environment variable, «ENV_VARIABLE» in Node.js?
Answers:
• process.env.ENV_VARIABLE
• process.argv.ENV_VARIABLE
• process.env.var.ENV_VARIABLE
• process.environment.ENV_VARIABLE
• process.argv.ENV_VARIABLE
• process.env.var.ENV_VARIABLE
• process.environment.ENV_VARIABLE
6. Which of the following will copy a file in Node.js?
Answers:
• var fs = require(‘fs’); fs.createReadStream(‘test.file’).pipe(fs.createWriteStream(‘newFile.file’));
• var fs = require(‘fs’); fs.createReadBuffer(‘test.file’).pipe(fs.createWriteBuffer(‘newFile.file’));
• var fs = require(‘file’); fs.createFileReader(‘test.file’).pipe(fs.createFileWriter(‘newFile.file’));
• var fs = require(‘fs’); fs.createReadBuffer(‘test.file’).stream(fs.createWriteBuffer(‘newFile.file’));
• var fs = require(‘fs’); fs.createReadBuffer(‘test.file’).pipe(fs.createWriteBuffer(‘newFile.file’));
• var fs = require(‘file’); fs.createFileReader(‘test.file’).pipe(fs.createFileWriter(‘newFile.file’));
• var fs = require(‘fs’); fs.createReadBuffer(‘test.file’).stream(fs.createWriteBuffer(‘newFile.file’));
7. Which of the following methods can be used to read the contents of a directory?
Answers:
• fs.readdir()
• fs.readdirSync()
• fs.readDirectory()
• fs.readdirAsync()
• fs.readdirSync()
• fs.readDirectory()
• fs.readdirAsync()
8. Which of the following statements is true about the console Object in Node.js?
Answers:
• «console.log» can take only a single argument.
• «console.log» prints to stdout without a newline.
• Its functions are synchronous when the destination is a terminal or a file, and asynchronous when it’s a pipe.
• Its functions are asynchronous when the destination is a terminal or a file, and synchronous when it’s a pipe.
• «console.log» prints to stdout without a newline.
• Its functions are synchronous when the destination is a terminal or a file, and asynchronous when it’s a pipe.
• Its functions are asynchronous when the destination is a terminal or a file, and synchronous when it’s a pipe.
9. Which of the following statements is true about the process object in Node.js?
Answers:
• It is a local object.
• It is an instance of the events.EventEmitter class.
• The process.exit(1) method ends the process with a «success» code.
• «process.stderr» and «process.stdout» are non-blocking if they refer to regular files or TTY file descriptors.
• It is an instance of the events.EventEmitter class.
• The process.exit(1) method ends the process with a «success» code.
• «process.stderr» and «process.stdout» are non-blocking if they refer to regular files or TTY file descriptors.
10. Which of the following NPM commands will install both dependencies and devDependencies of a given project?
Answers:
• npm instal
• npm install –dev
• npm install –production
• None of these
• npm install –dev
• npm install –production
• None of these
11. What does the following command do? npm view <package-name> version
Answers:
• It shows the version of the package installed globally.
• It shows the version of the package installed locally.
• It shows the version of the package that is cached.
• It shows the latest version of the package that is available.
• It shows the version of the package installed locally.
• It shows the version of the package that is cached.
• It shows the latest version of the package that is available.
12. Which of the following methods will print to the console without a trailing new line?
Answers:
• process.stdout.print()
• console.error()
• console.log()
• process.stdout.write()
• console.error()
• console.log()
• process.stdout.write()
13. Which of the following statements are true about the module.exports object in Node.js?
Answers:
• It is the object that gets returned from a require() call.
• It can be assigned in a callback.
• Assigning an export object to module.exports will rebind the local exports variable.
• None of these.
• It can be assigned in a callback.
• Assigning an export object to module.exports will rebind the local exports variable.
• None of these.
14. Which array contains the command line arguments in Node.js?
Answers:
• process.argv
• args.argv
• arguments.argv
• env.argv
• args.argv
• arguments.argv
• env.argv
15. Which of the following can be used to get the currently running script’s path in Node.js?
Answers:
• __filename
• os.tmpdir()
• path.dirname()
• path.basename()
• os.tmpdir()
• path.dirname()
• path.basename()
16. Which of the following methods can be used to write a file in Node.js?
Answers:
• fs.write()
• fs.writeFile()
• fs.createWriteStream()
• fs.writeStream()
• fs.writeFile()
• fs.createWriteStream()
• fs.writeStream()
17. What does the following code do?
var http = require(‘http’);
var fs = require(‘fs’);
file = fs.createWriteStream(«file.png»);var request = http.get(«http://path/to/file.png», function(response) { response.pipe(file); });
Answers:
• It creates an HTTP GET request and pipes its response into a writeable file stream.
• It creates an HTTP GET request, and synchronously pipes its response into a writeable file stream.
• It creates an HTTP POST request and pipes its response into a readable file stream.
• It creates an HTTP POST request and pipes its response into a writeable file stream.
• It creates an HTTP GET request, and synchronously pipes its response into a writeable file stream.
• It creates an HTTP POST request and pipes its response into a readable file stream.
• It creates an HTTP POST request and pipes its response into a writeable file stream.
18. Which of the following statements are true about the child_process module in Node.js?
Answers:
• It is not possible to stream data through a child process’ stdin, stdout, and stderr in a fully non-blocking way.
• Child processes always have two streams associated with them.
• «require(‘child_process’).spawn()» can be used to create a child process.
• «require(‘child_process’).fork()» can be used to create a child process.
• Child processes always have two streams associated with them.
• «require(‘child_process’).spawn()» can be used to create a child process.
• «require(‘child_process’).fork()» can be used to create a child process.
19. Which of the following will open a file, then read its contents one line at a time?
Answers:
• fs.readFileStream()
• fs.readFile()
• fs.createReadStream()
• fs.createFileStream()
• fs.readFile()
• fs.createReadStream()
• fs.createFileStream()
20. Which Node.js module can be used to get the IP address of the server the program is running on?
Answers:
• util
• os
• dns
• net
• os
• dns
• net
21. You are handling POST request to the server. Which express middleware gives access to the submitted form data?
Answers:
• bodyParser
• formHandler
• basicForms
• postHandler
• formHandler
• basicForms
• postHandler
22. Which of the following statement is valid ?
Answers:
• A. The exec() method runs a command in a shell and buffers the output.
• B. The exec() method returns a buffer with a max size.
• C. The exec() method waits for the process to end and tries to return all the buffered data at once.
• D. All of the above
• E. None of the above
• B. The exec() method returns a buffer with a max size.
• C. The exec() method waits for the process to end and tries to return all the buffered data at once.
• D. All of the above
• E. None of the above
23. Which of the following framework includes input validation?
Answers:
• Koa
• Hapi.js
• Express
• MEAN
• Hapi.js
• Express
• MEAN
24. In express application you are handling the route ‘/user/:name’. How could you access the ‘name’ property?
Answers:
• req.params.name
• req.prop.name
• req.query.name
• req.path.name
• req.prop.name
• req.query.name
• req.path.name
25. Which of the following names is second param of res.render method?
Answers:
• locals
• callback
• maxAge
• cacheControl
• callback
• maxAge
• cacheControl
26. Which of the following code is valid for printing current directory?
Answers:
• A. console.log(‘Current dir: ‘ + process.cwd());
• B. console.log(‘Current dir: ‘ + console.cwd());
• C. console.log(‘Current dir: ‘ + process.currenWorkingDirectory());
• D. None of the above
• E. All of the above
• B. console.log(‘Current dir: ‘ + console.cwd());
• C. console.log(‘Current dir: ‘ + process.currenWorkingDirectory());
• D. None of the above
• E. All of the above
27. Which of the following is package manager for Node?
Answers:
• Node
• NPM
• None of above
• NPM
• None of above
28. Which of the following template engines is working with Express.js?
Answers:
• HAML
• EJS
• Handlebars
• All of these
• EJS
• Handlebars
• All of these
29. Which of the correct way for Callback in NodeJS?
Answers:
• Callback is an Asynchronous equivalent for a function.
• Callback function is called before the completion of a given task
• Callback function is called at the completion of a given task
• All of above
• Callback function is called before the completion of a given task
• Callback function is called at the completion of a given task
• All of above
30. Which of the following statement is true ?
Answers:
• A. fs.close(fd, callback)
• B. fs.closeFile(fd, callback)
• C. fs.closePath(fd, callback)
• D. None of the above
• E. All of the above
• B. fs.closeFile(fd, callback)
• C. fs.closePath(fd, callback)
• D. None of the above
• E. All of the above
31. Which of the following statement is valid ?
Answers:
• A. package.json is present in the root directory of any Node application/module.
• B. package.json is used to define the properties of a package.
• C. package.json can be used to update dependencies of a Node application.
• D. A and B both are true
• E. All of the above
• B. package.json is used to define the properties of a package.
• C. package.json can be used to update dependencies of a Node application.
• D. A and B both are true
• E. All of the above
32. Which of the following command will show all the modules installed locally?
Answers:
• $ npm ls -g
• node ls -g
• npm ls
• node ls
• node ls -g
• npm ls
• node ls
33. Which of the following statement is valid?
Answers:
• A. Node implements File I/O using simple wrappers around standard POSIX functions.
• B. Node File System (fs) module should be imported for File I/O opearations.
• C. Both of the above
• D. None of the above
• B. Node File System (fs) module should be imported for File I/O opearations.
• C. Both of the above
• D. None of the above
34. Which of the following is the correct Connect middleware function signature?
Answers:
• function(req, res, next)
• function(req, res)
• function()
• function(err, req, res)
• function(req, res)
• function()
• function(err, req, res)
35. Which of the following methods to checks modifications in files?
Answers:
• watch
• watchDir
• watchFilesList
• All of these
• watchDir
• watchFilesList
• All of these
36. Which of the following framewroks is most popular Node.js framework?
Answers:
• Koa
• Express
• Hapi
• Total.js
• Express
• Hapi
• Total.js
37. Node.js should not be used in the __ area?
Answers:
• A. Single Page Applications
• B. JSON APIs based Applications
• C. CPU intensive applications
• D. Data Intensive Realtime Applications (DIRT)
• B. JSON APIs based Applications
• C. CPU intensive applications
• D. Data Intensive Realtime Applications (DIRT)
38. Which of the following modes supports fs.open method?
Note: There may be more than one right answer.
Answers:
• rs
• ks
• a+
• ax
• ks
• a+
• ax
39. Would you like to use session storage in your application and which one would be the right way to do it?
Answers:
• var app = require(‘express’)();
app.use(express.cookieParser());
app.use(express.session({secret: ‘1234567890QWERTY’}));
app.use(function(req,res,next) {
req.session.data = ‘Critical info’;
next();
}
• var express = require(‘express’);
var app = express();
app.use(express.session({secret: ‘1234567890QWERTY’}));
app.use(function(req,res,next) {
req.session.data = ‘Critical info’;
next();
}
• var app = require(‘express’)();
app.use(express.cookieParser());
app.use(express.session({secret: ‘1234567890QWERTY’}));
app.get(‘/’, function(req,res) {
req.session = ‘Critical info’;
res.send(‘session data set’);
}
• var express = require(‘express’);
var app = express();
store = new express.session.MemoryStore;
app.use(express.session({ secret: ‘1234567890QWERTY’, store: store }));
app.get(‘/’, function(req,res) {
req.session = ‘Critical info’;
res.send(‘session data set’);
}
app.use(express.cookieParser());
app.use(express.session({secret: ‘1234567890QWERTY’}));
app.use(function(req,res,next) {
req.session.data = ‘Critical info’;
next();
}
• var express = require(‘express’);
var app = express();
app.use(express.session({secret: ‘1234567890QWERTY’}));
app.use(function(req,res,next) {
req.session.data = ‘Critical info’;
next();
}
• var app = require(‘express’)();
app.use(express.cookieParser());
app.use(express.session({secret: ‘1234567890QWERTY’}));
app.get(‘/’, function(req,res) {
req.session = ‘Critical info’;
res.send(‘session data set’);
}
• var express = require(‘express’);
var app = express();
store = new express.session.MemoryStore;
app.use(express.session({ secret: ‘1234567890QWERTY’, store: store }));
app.get(‘/’, function(req,res) {
req.session = ‘Critical info’;
res.send(‘session data set’);
}
40. Which of the following libraries using to mocking modules?
Note: There may be more than one right answer.
Answers:
• Rewire
• Mockery
• Stub
• All of these
• Mockery
• Stub
• All of these
41. Which of the following command creates a server ?
Answers:
• A. net.createServer([options][, connectionListener])
• B. net.connect(options[, connectionListener])
• C. net.createConnection(port[, host][, connectListener])
• D. None of the above
• B. net.connect(options[, connectionListener])
• C. net.createConnection(port[, host][, connectListener])
• D. None of the above
42. Which of the following module is required for path specific questions?
Answers:
• fs module
• os module
• path module
• None of the above
• os module
• path module
• None of the above
43. Which of the following routing methods available in NodeJS?
Note: There may be more than one right answer.
Answers:
• header
• get
• post
• delete
• get
• post
• delete
44. Why Underscore Variable is used in REPL session?
Answers:
• A. to get the last command used.
• B. to get the last result.
• C. to store the result.
• D. None of the above
• B. to get the last result.
• C. to store the result.
• D. None of the above
45. Which of the following classes is the parent for repl.REPLServer class?
Answers:
• REPL.Interface
• readline.Interfase
• REPL
• REPLSERVER
• readline.Interfase
• REPL
• REPLSERVER
46. For Linux, Which of the following environment variable need to set for successfully NodeJS installation?
Answers:
• export PATH=$PATH:/usr/local/nodejs/bin
• export NODE=$PATH:/usr/local/nodejs/bin
• None of above
• export NODE=$PATH:/usr/local/nodejs/bin
• None of above
47. Which of the following statement is correct ?
Answers:
• A. The __dirname represents the name of the directory that the currently executing script resides in.
• B. The __dirname represents the resolved absolute path of code file.
• C. Both of the above
• D. None of the above
• B. The __dirname represents the resolved absolute path of code file.
• C. Both of the above
• D. None of the above
48. Which of the following module is required to create child process?
Answers:
• exec
• spawn
• child_process
• None of the above
• spawn
• child_process
• None of the above
49. Which of the following are supported Template engine?
Note: There may be more than one right answer.
Answers:
• abd
• atpl
• jade
• haml
• hamlet
• All of the above
• atpl
• jade
• haml
• hamlet
• All of the above
50. Which of the following is operates asynchronous logic?
Note: There may be more than one right answer.
Answers:
• Callbacks
• Loops
• Event Emitters
• All of the above
• Loops
• Event Emitters
• All of the above
51. How would you get operating system name?
Answers:
• os.type();
• os.arch();
• os.platform();
• os.name();
• os.arch();
• os.platform();
• os.name();
52. Which of the following implements stream.Readable interface?
Note: There may be more than one right answer.
Answers:
• http.IncomingMessage
• fs.ReadStream
• net.Socket
• process.stdin
• process.stdout
• fs.ReadStream
• net.Socket
• process.stdin
• process.stdout
53. What is the use of Underscore variable in REPL session?
Answers:
• To store the result
• To get the last command used
• To get the last result
• None of the above
• To get the last command used
• To get the last result
• None of the above
54. Which of the following classes exposes raw memory allocation outside the V8 heap?
Answers:
• Buffer
• Stream
• Cluster
• Cache
• Stream
• Cluster
• Cache
55. Which array contains the command line arguments in Node.js?
Answers:
• process.argv
• args.argv
• arguments.argv
• env.argv
• args.argv
• arguments.argv
• env.argv
56. Which of the following flags working with npm?
Note: There may be more than one right answer.
Answers:
• -O
• -P
• -R
• -S
• -P
• -R
• -S
57. Which of the following is the result of module.id ?
Answers:
• file name
• 3-byte machine identifier
• 2-byte process id
• 3-byte process id
• 3-byte machine identifier
• 2-byte process id
• 3-byte process id
58. Which of the following keywords is using to achieve await-like behaviour?
Answers:
• yield
• yields
• async
• async-await
• yields
• async
• async-await
59. Which of the following will open a file, then read its contents one line at a time?
Answers:
• fs.readFileStream()
• fs.readFile()
• fs.createReadStream()
• fs.createFileStream()
• fs.readFile()
• fs.createReadStream()
• fs.createFileStream()
60. Which of the following statement is valid?
Answers:
• A. The fork() method method is a special case of the spawn() to create Node processes.
• B. The fork method returns object with a built-in communication channel in addition to having all the methods in a normal Child Process instance.
• C. Both of the above
• D. None of the above
• B. The fork method returns object with a built-in communication channel in addition to having all the methods in a normal Child Process instance.
• C. Both of the above
• D. None of the above
61. Consider the following contents of cube.js , How could you get the volume of a cube utilising this module?
module.exports = function(a) {
return {
volume: function() {
return a * a * a;
}
};
}
Answers:
• var cube = require(‘./cube.js’);
var a = cube(2);
var volume = a.volume();
• var cube = require(‘./cube.js’);
var a = cube();
var volume = a.volume(2);
• var cube = require(‘./cube.js’);
var volume = cube(2);
• var cube = require(‘./cube.js’);
var a = cube(2);
var volume = a.volume;
var a = cube(2);
var volume = a.volume();
• var cube = require(‘./cube.js’);
var a = cube();
var volume = a.volume(2);
• var cube = require(‘./cube.js’);
var volume = cube(2);
• var cube = require(‘./cube.js’);
var a = cube(2);
var volume = a.volume;
62. Which of the following variables you can use in modules?
Note: There may be more than one right answer.
Answers:
• __filename
• __directory
• __dirname
• __filesize
• __directory
• __dirname
• __filesize
63. Let’s say you have a file square.js with the following contents, Which are the appropriate ways to use the area function from within other module?
exports.area = function (a) {
return a*a;
}
Answers:
• var square = require(‘./square.js’);
var sqArea = square.area(3);
• var square = require(‘./square.js’);
var sqArea = square(3);
• var sqArea = require(‘./square.js’).area(3);
• var square = module(‘./square.js’);
var sqArea = square.area(3);
var sqArea = square.area(3);
• var square = require(‘./square.js’);
var sqArea = square(3);
• var sqArea = require(‘./square.js’).area(3);
• var square = module(‘./square.js’);
var sqArea = square.area(3);
64. Which of the following file extensions supports Node Module System ?
Answers:
• .js
• .json
• .node
• All of these
• .json
• .node
• All of these
65. Which of the following statement is correct while using a Node module http in a Node based application?
Answers:
• A. var http = import(«http»);
• B. package http;
• C. import http;
• D. var http = require(«http»);
• B. package http;
• C. import http;
• D. var http = require(«http»);
66. You have a file rect.js with the following contents, What would be the appropriate ways to call the exported function?
module.exports = function area(a, b) {
return a*b;
}
Answers:
• var rect = require(‘./rect.js);
var area = rect(3);
• var rect = require(‘./rect.js);
var area = rect.area(3);
• var area = require(‘./rect.js’)(3);
• var area = require(‘./rect.js’).area(3);
var area = rect(3);
• var rect = require(‘./rect.js);
var area = rect.area(3);
• var area = require(‘./rect.js’)(3);
• var area = require(‘./rect.js’).area(3);
67. Which of the following utility modules available in NodeJS?
Answers:
• OS
• path
• net
• DNS
• All of above
• path
• net
• DNS
• All of above
68. Which are the following debug command to debug node server?
Note: There may be more than one right answer.
Answers:
• node debug <test.js>
• npm debug <test.js>
• node debug -p <pid>
• node debug <URI>
• All of the above
• npm debug <test.js>
• node debug -p <pid>
• node debug <URI>
• All of the above
69. Which of the following is correct ?
Answers:
• A. Chanining is a mechanism to connect output of one stream to another stream and create a chain of multiple stream operations.
• B. Chanining is normally used with piping operations.
• C. Both of the above
• D. None of the above
• B. Chanining is normally used with piping operations.
• C. Both of the above
• D. None of the above
70. What REST stands for?
Answers:
• Representational State Transfer
• Resource Efficient State Transfer
• Real Elegant State Transfer
• Resource Elegant State Transfer
• Resource Efficient State Transfer
• Real Elegant State Transfer
• Resource Elegant State Transfer
71. Which of the following statement is true about the fs module of Node?
Answers:
• Asynchronous methods of fs module take last parameter as completion function callback
• Every method in fs module have synchronous as well as asynchronous form
• Both of the above
• None of the above
• Every method in fs module have synchronous as well as asynchronous form
• Both of the above
• None of the above
72. How would you start node with debugger?
Answers:
• node debug myscript.js
• node myscript.js —debug
• node myscript.js —debugger
• node myscript.js
• node myscript.js —debug
• node myscript.js —debugger
• node myscript.js
73. Which of the following events are emitted by the Readable Stream?
Note: There may be more than one right answer.
Answers:
• ‘data’
• ‘end’
• ‘error’
• ‘response’
• ‘drain’
• ‘end’
• ‘error’
• ‘response’
• ‘drain’
74. What is default action for the case when we don’t catch the exception and it bubbles all the way back to the event loop?
Answers:
• print a stack trace and exit
• print a stack trace and continue execution
• print an exception message and restart the program
• exit program immediately
• print a stack trace and continue execution
• print an exception message and restart the program
• exit program immediately
75. Which command enables you to input data using keyboard into your node application?
Answers:
• process.stdin.resume();
• process.stdin.pause();
• console.read();
• console.readln();
• process.stdin.pause();
• console.read();
• console.readln();
76. APIs of Node.JS are __?
Answers:
• A. Asynchronous
• B. Synchronous
• C. Both of the above
• D. None of the above
• B. Synchronous
• C. Both of the above
• D. None of the above
77. Which of the following values can return async functions?
Answers:
• function
• object
• string
• Non of these
• object
• string
• Non of these
78. Which of the following values is correct about how many lines defaults can be in NODE_REPL_HISTORY_SIZE?
Answers:
• 1000
• 1024
• 2000
• 2048
• 1024
• 2000
• 2048
79. Which of the following statement is valid?
Answers:
• A. on property is used to fire event.
• B. on property is used to bind a function with the event.
• C. on property is used to locate an event handler.
• D. None of the above
• B. on property is used to bind a function with the event.
• C. on property is used to locate an event handler.
• D. None of the above
80. Which of the following code print the name of operating system?
Answers:
• console.log(‘type : ‘ + os.type);
• console.log(‘type : ‘ + os.getType());
• console.log(‘type : ‘ + os.type());
• None of the above
• console.log(‘type : ‘ + os.getType());
• console.log(‘type : ‘ + os.type());
• None of the above
81. How can you stop reading from stdin?
Answers:
• process.stdin.pause();
• process.stdin.end();
• process.stdin.close();
• process.stdin.stop();
• process.stdin.end();
• process.stdin.close();
• process.stdin.stop();
82. Which of the following will remove a file from your file system?
Answers:
• var cb = function(err) { if (err) throw err; console.log(‘success deleting file’); }
require(‘fs’).remove(‘filename’, cb);
• var cb = function(err) { if (err) throw err; console.log(‘success deleting file’); }
require(‘fs’).rm(‘filename’, cb);
• var cb = function(err) { if (err) throw err; console.log(‘success deleting file’); }
require(‘fs’).unlink(‘filename’, cb);
• require(‘fs’).removeSync(‘filename’, cb);
console.log(‘success deleting file’);
require(‘fs’).remove(‘filename’, cb);
• var cb = function(err) { if (err) throw err; console.log(‘success deleting file’); }
require(‘fs’).rm(‘filename’, cb);
• var cb = function(err) { if (err) throw err; console.log(‘success deleting file’); }
require(‘fs’).unlink(‘filename’, cb);
• require(‘fs’).removeSync(‘filename’, cb);
console.log(‘success deleting file’);
83. Which of the following engine built of NodeJS framework/platform?
Answers:
• Firefox’s JavaScript V8 Engine
• Google Chrome’s JavaScript V8 Engine
• None of above
• Google Chrome’s JavaScript V8 Engine
• None of above
84. Which of the following should not to use in NodeJS?
Answers:
• I/O bound Applications
• CPU Intensive Applications
• Data Streaming Applications
• Data Intensive Real-time Applications
• CPU Intensive Applications
• Data Streaming Applications
• Data Intensive Real-time Applications
85. Which of the following events would be fired in http module when a new TCP stream is established?
Answers:
• ‘connection’
• ‘request’
• ‘stream’
• ‘connect’
• ‘request’
• ‘stream’
• ‘connect’
86. Which of the following statement is correct ?
Answers:
• A. Webservices based on REST Architecture are known as RESTful web services.
• B. Webservices uses HTTP methods to implement the concept of REST architecture.
• C. Both of the above
• D. None of the above
• B. Webservices uses HTTP methods to implement the concept of REST architecture.
• C. Both of the above
• D. None of the above
87. Route path: /train/from-:to
Request URL: <a href=»http://localhost:3000/train/AHM-BRD»>http://localhost:3000/train/AHM-BRD</a>
What should be request params?
Answers:
• { «from»: «AHM», «to»: «BRD» }
• { «train»: «AHM», «to»: «BRD» }
• { «from»: «AHM», «train»: «BRD» }
• None of the above
• { «train»: «AHM», «to»: «BRD» }
• { «from»: «AHM», «train»: «BRD» }
• None of the above
88. What happens when executing the following code?
assert = require(‘assert’);
assert(false, ‘assert false’);
Answers:
• assert throws an AssertionError, program execution stops
• assert throws an AssertionError, program execution continues
• ‘assert false’ is printed to console, program execution continues
• assertion fails, ‘assert false’ is printed to console, program execution stops
• assert throws an AssertionError, program execution continues
• ‘assert false’ is printed to console, program execution continues
• assertion fails, ‘assert false’ is printed to console, program execution stops
89. How would you get the filename of the code being executed?
Answers:
• __filename
• __dirname + __filename
• module.__filename
• module.__dirname + module.__filename
• __dirname + __filename
• module.__filename
• module.__dirname + module.__filename
90. Which of the following ways to create a child process?
Answers:
• exec() method
• spawn() method
• fork() method
• All of the above
• None of the above
• spawn() method
• fork() method
• All of the above
• None of the above
91. Which of the following libs provides basic HTTP authentication for protecting data?
Answers:
• auth-base
• basicAuth
• connect
• http
• basicAuth
• connect
• http
92. Which of the following libs using for debugging node-applications?
Answers:
• npm-debug
• node-debugger
• node-inspector
• debugger
• node-debugger
• node-inspector
• debugger
93. NodeJS includes a full-featured out-of-process debugging utility accessible via a which protocol?
Answers:
• TCP-based protocol
• UDP-based protocol
• All of the above
• UDP-based protocol
• All of the above
94. How can you check if two arrays (a1 and a2) are equal element by element using ‘assert’ module?
Answers:
• assert.deepEqual(a1, a2)
• assert.strictEqual(a1, a2)
• assert.arrayEqual(a1, a2)
• assert(a1 == a2)
• assert.strictEqual(a1, a2)
• assert.arrayEqual(a1, a2)
• assert(a1 == a2)
95. How to enabled V8 inspector for debug?
Note: There may be more than one right answer.
Answers:
• —inspect
• —inspect=<PORT>
• —debug=<PORT>
• All of the above
• —inspect=<PORT>
• —debug=<PORT>
• All of the above
96. Which module of core node.js API is used for writing unit tests for your applications?
Answers:
• assert
• should
• mocha
• jsUnit
• should
• mocha
• jsUnit
97. Suppose we have this construction in Express.js project , Which of the following paths will match this route?
app.get(/.*moon$/, function(req, res) {
return res.send(‘/.*moon$/’);
});
Answers:
• moonlight
• moon
• moonbeam
• comoon
• moon
• moonbeam
• comoon
98. Which of the following commands exit from REPL?
Answers:
• ctrl+X
• ESC
• double ctrl+c
• ctrl+c
• ESC
• double ctrl+c
• ctrl+c
99. Suppose we have this construction in Expres.js project,Which of the following paths will match this route?
app.get(‘/kl+mn’, function(req, res) {
return res.send(‘kl+mn’);
});
Answers:
• klmn
• kllmn
• kmcd
• All of these.
• kllmn
• kmcd
• All of these.
100. How would you get the number of CPU’s in your machine?
Answers:
• require(‘os’).cpus().length;
• process.cpus.length;
• system.cpu.length;
• require(‘os’).cpus();
• process.cpus.length;
• system.cpu.length;
• require(‘os’).cpus();
101. Which of the following files using for setting start point in deployment services?
Answers:
• .travis.yml
• PROCFILE
• .CONFIG
• .npm-start
• PROCFILE
• .CONFIG
• .npm-start
102. How would you get the name of the JavaScript file being executed?
Answers:
• process.argv[1]
• __filename
• process.__filename
• __dirname + __filename
• __filename
• process.__filename
• __dirname + __filename
103. Which of the libs are exists in Node Core Libraries?
Note: There may be more than one right answer.
Answers:
• .Net
• HTTP
• STDLIB
• Path
• HTTP
• STDLIB
• Path
104. Which statement best describes console functions behavior?
Answers:
• The console functions are synchronous when the destination is a terminal or a file and asynchronous when it’s a pipe.
• The console functions are always asynchronous.
• The console functions are always synchronous.
• The console functions are always asynchronous, except for when they are called from the child process.
1. Which Node.js module can be used to get the IP address of the server the program is running on?
Answers:
var http = require(‘http’);
var fs = require(‘fs’);
var file = fs.createWriteStream(“file.png”);
var request = http.get(“http://path/to/file.png”, function(response) {
response.pipe(file);
});
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
npm view <package-name> version
Answers:
Answers:
Answers:
Answers:
Answers:
• The console functions are always asynchronous.
• The console functions are always synchronous.
• The console functions are always asynchronous, except for when they are called from the child process.
1. Which Node.js module can be used to get the IP address of the server the program is running on?
Answers:
- util
- os
- dns
- net
var http = require(‘http’);
var fs = require(‘fs’);
var file = fs.createWriteStream(“file.png”);
var request = http.get(“http://path/to/file.png”, function(response) {
response.pipe(file);
});
Answers:
- It creates an HTTP GET request and pipes its response into a writeable file stream.
- It creates an HTTP GET request, and synchronously pipes its response into a writeable file stream.
- It creates an HTTP POST request and pipes its response into a readable file stream.
- It creates an HTTP POST request and pipes its response into a writeable file stream.
Answers:
- fs.write()
- fs.writeFile()
- fs.createWriteStream()
- fs.writeStream()
Answers:
- process.stdout.print()
- console.error()
- console.log()
- process.stdout.write()
Answers:
- It is a local object.
- It is an instance of the events.EventEmitter class.
- The process.exit(1) method ends the process with a “success” code.
- “process.stderr” and “process.stdout” are non-blocking if they refer to regular files or TTY file descriptors.
Answers:
- fs.exists()
- fs.existsSync()
- fs.checkFileSync()
- fs.checkDirSync()
Answers:
- fs.readdir()
- fs.readdirSync()
- fs.readDirectory()
- fs.readdirAsync()
Answers:
- npm upgrade -g
- npm install -uga
- npm update -g
- npm version –install-latest
Answers:
- It is not possible to stream data through a child process’ stdin, stdout, and stderr in a fully non-blocking way.
- Child processes always have two streams associated with them.
- “require(‘child_process’).spawn()” can be used to create a child process.
- “require(‘child_process’).fork()” can be used to create a child process.
Answers:
- process.argv
- args.argv
- arguments.argv
- env.argv
Answers:
- var fs = require(‘fs’); fs.createReadStream(‘test.file’).pipe(fs.createWriteStream(‘newFile.file’));
- var fs = require(‘fs’); fs.createReadBuffer(‘test.file’).pipe(fs.createWriteBuffer(‘newFile.file’));
- var fs = require(‘file’); fs.createFileReader(‘test.file’).pipe(fs.createFileWriter(‘newFile.file’));
- var fs = require(‘fs’); fs.createReadBuffer(‘test.file’).stream(fs.createWriteBuffer(‘newFile.file’));
Answers:
- It is the object that gets returned from a require() call.
- It can be assigned in a callback.
- Assigning an export object to module.exports will rebind the local exports variable.
- None of these.
Answers:
- fs.readFileStream()
- fs.readFile()
- fs.createReadStream()
- fs.createFileStream()
Answers:
- npm install
- npm install –dev
- npm install –production
- None of these
Answers:
- “console.log” can take only a single argument.
- “console.log” prints to stdout without a newline.
- Its functions are synchronous when the destination is a terminal or a file, and and asynchronous when it’s a pipe.
- Its functions are asynchronous when the destination is a terminal or a file, and and synchronous when it’s a pipe.
npm view <package-name> version
Answers:
- It shows the version of the package installed globally.
- It shows the version of the package installed locally.
- It shows the version of the package that is cached.
- It shows the latest version of the package that is available.
Answers:
- __filename
- os.tmpdir()
- path.dirname()
- path.basename()
Answers:
- process.env.ENV_VARIABLE
- process.argv.ENV_VARIABLE
- process.env.var.ENV_VARIABLE
- process.environment.ENV_VARIABLE
Answers:
- node
- The file path of the JavaScript file.
- The first command line argument.
- The second command line argument.
Answers:
- -g
- –global
- -l
- –link
Very nice blog. Thanks for sharing
ReplyDeleteNode JS Online training
Node JS training in Hyderabad