Thursday, November 10, 2016

Node.js Test 2016 – Upwork Test Answers


Node.js Test, Node.js Test Answers 2016, Upwork, Upwork test, Upwork test Answer, Upwork test Answers, Upwork test Answers 2016, oDesk test Answers, oDesk test Answers 2016



Upwork Node.js Test 2016






 20 Answered Test Questions:
1. Which Node.js module can be used to get the IP address of the server the program is running on?
Answers:
a. util
a. os
a. dns
a. net
2. What does the following code do?
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:
a. It creates an HTTP GET request and pipes its response into a writeable file stream. 
a. It creates an HTTP GET request, and synchronously pipes its response into a writeable file stream.
a. It creates an HTTP POST request and pipes its response into a readable file stream.
a. It creates an HTTP POST request and pipes its response into a writeable file stream.
3. Which of the following methods can be used to write a file in Node.js?
Answers:
a. fs.write()
a. fs.writeFile()
a. fs.createWriteStream()
a. fs.writeStream()
4. Which of the following methods will print to the console without a trailing new line?
Answers:
a. process.stdout.print()
a. console.error()
a. console.log()
a. process.stdout.write()
5. Which of the following statements is true about the process object in Node.js?
Answers:
a. It is a local object.
a. It is an instance of the events.EventEmitter class. 
a. The process.exit(1) method ends the process with a “success” code.
a. “process.stderr” and “process.stdout” are non-blocking if they refer to regular files or TTY file descriptors.
6. Which of the following will synchronously check if a file/directory exists?
Answers:
a. fs.exists()
a. fs.existsSync()
a. fs.checkFileSync()
a. fs.checkDirSync()
7. Which of the following methods can be used to read the contents of a directory?
Answers:
a. fs.readdir()
a. fs.readdirSync()
a. fs.readDirectory()
a. fs.readdirAsync()
8. Which of the following console commands will update all installed global packages to the latest available versions?
Answers:
a. npm upgrade -g
a. npm install -uga
a. npm update -g
a. npm version –install-latest
9. Which of the following statements are true about the child_process module in Node.js?
Answers:
a. It is not possible to stream data through a child process’ stdin, stdout, and stderr in a fully non-blocking way.
a. Child processes always have two streams associated with them.
a. “require(‘child_process’).spawn()” can be used to create a child process.
a. “require(‘child_process’).fork()” can be used to create a child process. 
10. Which array contains the command line arguments in Node.js?
Answers:
a. process.argv
a. args.argv
a. arguments.argv
a. env.argv
11. Which of the following will copy a file in Node.js?
Answers:
a. var fs = require(‘fs’); fs.createReadStream(‘test.file’).pipe(fs.createWriteStream(‘newFile.file’)); 
a. var fs = require(‘fs’); fs.createReadBuffer(‘test.file’).pipe(fs.createWriteBuffer(‘newFile.file’));
a. var fs = require(‘file’); fs.createFileReader(‘test.file’).pipe(fs.createFileWriter(‘newFile.file’));
a. var fs = require(‘fs’); fs.createReadBuffer(‘test.file’).stream(fs.createWriteBuffer(‘newFile.file’));
12. Which of the following statements are true about the module.exports object in Node.js?
Answers:
a. It is the object that gets returned from a require() call. 
a. It can be assigned in a callback.
a. Assigning an export object to module.exports will rebind the local exports variable.
a. None of these.
13. Which of the following will open a file, then read its contents one line at a time?
Answers:
a. fs.readFileStream()
a. fs.readFile()
a. fs.createReadStream()
a. fs.createFileStream()
14. Which of the following NPM commands will install both dependencies and devDependencies of a given project?
Answers:
a. npm install
a. npm install –dev
a. npm install –production
a. None of these
15. Which of the following statements is true about the console Object in Node.js?
Answers:
a. “console.log” can take only a single argument.
a. “console.log” prints to stdout without a newline.
a. Its functions are synchronous when the destination is a terminal or a file, and and asynchronous when it’s a pipe. 
a. Its functions are asynchronous when the destination is a terminal or a file, and and synchronous when it’s a pipe.
16. What does the following command do?
npm view version
Answers:
a. It shows the version of the package installed globally.
a. It shows the version of the package installed locally.
a. It shows the version of the package that is cached.
a. It shows the latest version of the package that is available. 
17. Which of the following can be used to get the currently running script’s path in Node.js?
Answers:
a. __filename
a. os.tmpdir()
a. path.dirname()
a. path.basename()
18. Which of the following can be used to access the environment variable, “ENV_VARIABLE” in Node.js?
Answers:
a. process.env.ENV_VARIABLE
a. process.argv.ENV_VARIABLE
a. process.env.var.ENV_VARIABLE
a. process.environment.ENV_VARIABLE
19. What does process.argv[1] contain?
Answers:
a. node
a. The file path of the JavaScript file. 
a. The first command line argument.
a. The second command line argument.
20. 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:
a. -g
a. –global
a. -l
a. –link






No comments:

Post a Comment

Earn for Free

http://hiredrmjru.trade/3670784521590/