Elance Node.js Test Answers 2015



What program is used to programmtically control the browser?
perl
vbscript
C#
javascript


Which of the following is a standard node module, included with the default install?
async
fs
csv
request


Where does Node run on your machine?
in your TIF file
in the registry
in your browser
as an application


WebSockets with Socket.io can be used to?
All of these.
Send messages from the client to the server.
Send messages from the server to the client.
Send messages from one client to another.


What is the code to access the DNS module?
req('dns');
npm_module('dns');
require('dns');
request(dns);


How do you call a function attached to an object that will be executed when the object emits an event?
Link
Listener
Buffer
Process
Log


NPM is a...
Package manager
Web Server
Sweet Acronym
Module


Node.js is stored on your____?
hard drive
power supply
motherboard
serial bus


What Javascript Engine does node.js use?
Rhino
J├ĄgerMonkey
V8
SpiderMonkey
Chakra


A module is an____?
Object
an event
variable
integer


If you have a node program called example.js, how would that be excuted?
node example.js
exec example.js
start example.js
launch example.js


Use _____ to step through your code.
URL string
breakpoints
manual
ruler


Why is Node.js important?
It allows asynchronous processing in the background without interupting the user
Javascript is powerless without the aid of Node.js
Browsers are weak, adding Node.js to your browser beefs it up
Chrome comes bundled with Node.js and everyong needs Chrome


What does Node.js run on?
database
SAN
server
client


What kind of application is better suited to node.js?
I/O Bound Applications
General Purpose Applications
CPU Bound Applications


A popular web application for framework for node?
express
spring
maven
tab


Which is of the following is a potential advantage of using Node.js?
Node.js is powered by a high-performance V8 engine.
Node.js is non-blocking and scalable.
All of these.
Node.js allows you use the same language on the server and client.


What function is used to write out application errors/events?
system.inform
util.log
process.write
console.log


How does one get access to Node.js?
a part of the OS
a part of the browser
a part of the registry
download the install


In node.js you can write and run code in what language?
Javascript and Java
Javascript
any language if you have the compiler for those installed on your machine
C++
Java


True or False: node.js can call other command line scripts.
False
True


What is a Buffer?
A String
Raw memory allocated outside the v8 heap
Similar to setTimeout in the browser


In this code: <code> function myLog(err, data) { console.log(err, data); } fs.readFile('/tmp/sample', myLog); </code> The function 'myLog' is used as a(an):
Filter
Object method
Callback
Prototype


What is node.js based on?
Cocoa's Unix backend
Unix's Websocket layer
Chrome's JavaScript runtime


How do you output to console in node.js?
trace or log
sys.puts or util.puts
util.log or console.log


What does "npm" stand for?
Node Package Manager
Node Packaged Modules
None of these
Node Process Manager


Which of the following can be created and managed using node.js?
Spambots
All of these
Data Compilers
Webservers
Chatrooms


What interface is used to access folders on your local drive
fso
drive
fs
file


How do you require a module?
<script src='mymodule' />
#include mymodule
var module = require('mymodule')
#import mymodule


Which of the following command-line arguments to "npm install" will allow a module to be installed outside the project folder?
--save
--global
--link


The "js" in Node.js stands for?
javascript
The creator of the language Jack Snyder
Junior Seau
doesn't stand for anything


REPL is:
Replicates an existing Buffer, optionally resetting the size
REnder PLaceholders - a templating function
A string replacement method
Read-Eval-Print-Loop, a way to interactively run code


Which is a comment in node?
>>Comment
?Comment
//comment
Comment


To declare a variable use what keyword?
float
integer
string
var


node.js excels at dealing with:
fibonacci benchmarks
I/O-bound tasks
JRE optimization


Running the following code, what will the console output? var http = require('http'); http.createServer( function (request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello World\n'); } ).listen(8000); console.log('Server running at http://localhost:8000/');
Hello World
Hello World\n
Server running at http://localhost:8000/
undefined


Which npm command will load all dependencies in the local node_modules folder?
npm run
npm start
npm load
npm install


How do you cause a function to be invoked at a specified time later?
process.wait(1000)
process.wait(fn, 1000)
wait(1000)
process.delay(1000, fn)
setTimeout(fn, 1000)


How can I call an object function from my module if my module name is "iModule"?
require('iModule').prototype.mObject();
request('iModule').mObject();
require('iModule').mObject();
import('iModule').mObject();


If you have a problem with your code, where would you look?
system.log
app.log
os.log
console.log


What does the require call return?
none of the above
module.exports object
string object


What is REPL?
Read-Eval-Print-Loop
Repeat Languages
Read-Edit-Place-Leverage


In the following Express route stack, which handler will be called for "GET /item/23"? app.get("/", routes.index ); app.get("/item", routes.item ); app.get("/item/:id", routes.id ); app.post("/item/:id", routes.post );
routes.id
routes.index
routes.post
routes.item


What interface is used to create a server through Node.js
web
server
url
http


What does the Zlib module provide?
Realtime application framework for Node.JS, with HTML5 WebSockets and cross-browser fallbacks support.
Bindings to Gzip/Gunzip, Deflate/Inflate, and DeflateRaw/InflateRaw classes
Bindings to application logging classes
It also offers a set of wrappers for OpenSSL's hash, hmac, cipher, decipher, sign and verify methods.


What method is used to parse JSON using NodeJS?
JSON.toJSON()
JSON.parseJSON()
JSON.parse();
None of the above


What is node.js?
A program written in Lisp
A program written in C
jQuery module
An Apache Module
Hardware


Which of these is a built-in module that can be used for unit testing in Node.js?
Test
Error
Fail
Assert


What does the following code do? var fs = require('fs'); var http = require('http'); var file = fs.createWriteStream("/tmp/file.png"); var req = http.get("http://example.com/file.png",function(resp){ resp.pipe(file); };
It throws an Error
It creates a GET request and pipes its response into a writeable file stream.
It creates an HTTP server that responds an image file for each requests


The Cryptography module requires OpenSSL.
Sometimes
True
False


Timer functions are built into node.js, you do not need to require() this module in order to use them.
true
false


True or False: node.js runs in a single thread.
True
False


The interactive shell is also called_____?
SIGINT
HTTPS
REPL
Interface


How do you start the node.js REPL?
noderepl
v8
node
nodejs


What syntax is correct for reading environment variable?
process.env.ENV_VARIABLE
node.environment.process['ENV_VARIABLE']
process.ENV_VARIABLE
process.environment.ENV_VARIABLE


Which function allows you to chain event listeners?
event()
chain()
connect()
on()


What do the lines like symbols = symbols || SYMBOLS_DEFAULT; do?
This is a JS idiom for overriding user inputted arguments.
This is a JS idiom for setting default arguments.
This is a JS idiom for checking that arguments are within a valid range.
This is a JS idiom for setting symbols to undefined.


To exit out of a function you should use _____?
(all of these)
exit;
return;
exit();


Given the following route and request, which Request object property will hold the value of 30 in the Express handler? Route: "/post/:id" Request: "/post/30?start=20"
req.id
req.params.id
req.query.id
req.params.post


Which company manages and maintains node.js?
Joyent
FreeNode
Google
Notch


Which of these statements about Express is true?
Express has built-in WebSocket support.
Express is an MVC framework.
Express is an NPM module.
Express comes packaged with Node.js.


The first argument passed to a Node.js asynchronous callback is always what?
A javascript promise.
The result of the function if there is one.
An Error object if an error has occured.
None of these.


Which of these is a valid way to output the contents of an array?
require('utils').print(array);
array.forEach(console.log);
console.log( array );


What is typically the first parameter in node.js callback functions?
Options
Result
Status
Function
Error


If an error occures in an Express middleware function, what is the best way to pass the error object to the subsequent handlers?
function( req, res ){ ... throw err; }
function( req, res, next){ ... next( err ); }
function( req, res){ ... res.error( err ); }
function( req, res ){ ... console.error( err ) }


By executing node without any arguments from the command-line:
you will be dropped into the REPL
node will ask you for arguments
nothing happens, node needs a file name argument such as "app.js" in order to start
you will receive an error message


net.Server emits an event every time a ____ connects to the server.
packet
peer
object
cat cable


To create an instance of the HTTP object, which function is used?
suggest
order
require
create


What built in class is a global type for dealing with binary data directly?
Cluster
Buffer
IO
Process


Which of these Express middleware stacks will NOT log favicon requests?
app.use(express.favicon()); app.use(express.logger()); app.use(express.static(__dirname + '/public'));
app.use(express.logger()); app.use(express.static(__dirname + '/public')); app.use(express.favicon());
app.use(express.static(__dirname + '/public')); app.use(express.logger()); app.use(express.favicon());


Node will run until its sure that no further ___ are available.
Utils
Events-handlers
Processes
Domains


In Express, which of these paths would NOT be cosumed by the following route? "/users/:id/:action?"
"/users/42"
"/users/123/edit"
"/users/test"
"/users"


Express middleware is actually handled by what other Node.js module?
Mocha
Connect
Request
Stack


In Express, which of these Response methods can NOT automatically end the response?
res.send()
res.render()
res.redirect()
res.type()


The VM module allows one to:
Manage the server's virtual memory
Run Java and .NET bytecode from within node
Run JavaScript code in a sandbox environment
Run alternative operating systems from within node


The process object is an instance of what class?
EventProcesser
NodeProcesser
EventEmitter
NPM


The process object is an instance of____?
EventProcess
EventEmitter
EventHandler
EventCommand


True or false? Node.js is multi-core by nature.
False
True
Only if compiled properly


Node.js is a truly parallel technology.
False
True


Which of the following methods will print to the console without a trailing new line?
process.stdout.write
util.puts
console.log
console.error


Which of these are valid ways to apply middleware in Express?
app.use( middleware );
All of these.
app.get("/route", middleware, routeHandler );
app.all("*", middleware);


Which of the following statements are true about the module.exports object?
Can be assigned in a callback
It's an alias to the exports object
It's a global object
It is the object returned from a require() call


Node.js clusters are child processes that do NOT share server ports?
false
true


Given the following route and request, which Request object property will hold the value of 20 in the Express handler? Route: "/post/:id" Request: "/post/30?start=20"
req.prop.start
req.query.start
req.start
req.params.start


var http_server = require('http'); how can you create a server?
http_server.startServer(function(){});
any of them
http.createServer(function(){});
http_server.createServer(function(){});
http.startServer(function(){});


What command is used to end a Node.JS process?
leave
quit
.exit
-q


Which of these is definitely true of Node.js?
Node.js is a high-level application framework.
Node.js is a very stable platform that is not likely to change in the future.
Node.js takes full advantage of multithreading.
Node.js can be used to create command line tools.


In Node.js, the result of an asynchronous function can be accessed how?
By the value returned by the callback.
By the value returned by the asynchronous function.
By the value passed as the first argument of the callback.
By the value passed as the second argument of the callback.


Is it possible to use jQuery on Node.js?
No, because Node.js isn't a browser.
Yes, with third party server-side DOM module.
Yes, natively.


Which of the following will copy a file?
var fs= require('fs'); fs.createReadBuffer('input.file').pipe(fs.createWriteBuffer('output.file'));
var fs= require('fs'); fs.readFile('input.file').pipe(fs.writeFile('output.file'));
var fs= require('fs'); fs.createReadStream('input.file').pipe(fs.createWriteStream('output.file'));
var fs= require('fs'); fs.createFileReader('input.file').pipe(fs.createFileWriter('output.file'));


If an EventEmitter object emits an 'error' event and there is no listener for it, node will:
Print a stack trace and continue running
Save a coredump file containing the error data
Print a stack trace and exit
Do nothing


To parse a URL string use____?
queryresolve
querystring
urlstring
urlparse


What is the name of the module system used in node.js?
CommonJS
None - node.js does not use modules
AMD
Both - developers choose on a per-module basis


Which of these are required fields in your package.json file?
"name", "version", and "dependancies"
"name"
"name", "version", and "description"
"name" and "version"


The Javascript used in node.js:
Is on-par with a recent version of IE
Is on-par with a recent version of Chrome
Is a full ECMAScript 4 implementation
Is limited to ECMAScript 2 subset
Is on-par with a recent version of WebKit


What is NOT a valid method to create a child process instance?
None of these
popen(3)
spawn()
fork()


What would be the value after that the timeouts has been fired? var x = 0; function callback(err,result){ if (err) { x--; return; } x++; } setTimeout(callback,10); setTimeout(callback,10,"Error");
1
0
2


Which Express middleware must come before express.session() in your stack?
express.bodyParser()
express.cookieParser()
express.sessionParser()
express.static()


The http.ServerResponse is an example of a what?
A pipe.
A writable Stream.
A callback.
A readable Stream.


Which of the following is not a global object in node.js?
process
console
path
none, node.js doesn't have global objects
Buffer


In Express, which of these would NOT expose the variable "title" to the template renderer?
res.render.title = "My App";
res.locals.title = "My App";
res.render("template",{ title: "My App" });
app.locals({ title: "My App" });


How do you properly timestamp a log message?
console.trace('message')
require('util').log('message')
console.debug('message')
console.log('message')


Which of these is NOT a global object?
Stream
console
process
Buffer
exports


Which of these is a valid way to output the contents of a file?
console.log( fs.readFile("file.txt") );
console.log( fs.readFileSync("file.txt") );
fs.readFileSync("file.txt", function(err,data){ console.log(data); });


What does process.argv[1] contain?
The absolute path of the running Javascript code.
The first command line argument.
"node"
The file path of the main Javascript file.


Which of the following method can't be used to write a file in Node.js?
fs.write()
fs.createWriteStream()
fs.writeFile()
fs.writeStream()


In the following Express routing method, what is the maximum number of arguments that may be passed to the callback function "routeHandler"? app.all("*", routeHandler )
4
2
1
3


Which of the following can be used to get the currently running code's absolute path?
__filename
process.argv[1]
path.dirname()


How do you create a new client connection via SSL?
tls.connect()
ssl.join()
ssl.connect()
ssl()


When creating a command line tool with Node.js, which expresion will allow you access the first command line argument?
process.argv[2]
process.argv[0]
process.argv[1]
process.execArgv[0]


If the Connect node package module is updated from version 2.8.5 to version 3.1.0 which dependency in your package.json file may break your application on update?
"connect": ">=2.0.0 <2.8.5"
"connect": ">=2.5"
"connect": "1.0.0"
"connect": "2.x"


Which express 3 middleware has _NOT_ been moved into its own module in express 4.
error-handler
logger
static
session


What is the default memory limit on a node process?
512mb on 32-bit systems, and 1gb on 64-bit systems.
1gb on 32-bit systems, and 2gb on 64-bit systems.
No Limit


Is it possible to execute node.js system command synchronously?
Yes, with a third party library
Yes, built in by default.
No


What is the default request limit to the same origin on a node.js http client?
1
unlimited
10
5


Which of these is not a valid version according to npm semantic versioning?
"1.2.3b"
"1.2.3-rc4"
"1.2.3+build4"
"v1.2.3"


Which of the following is NOT true about Node 0.6?
Integrated master-worker support for load-balancing
Windows binary distributed
Native gzip support
Integrated command-line debugger
Unix binary distributed


Which of the following Node.js module can be used to get the IP address of the server the program is running on?
http
os
net
dns
util


Which is a correct way to check the latest released version of the Express module with npm?
npm express version
npm show version express
npm version express
npm view express version


A Buffer can be resized.
False
Sometimes
True

No comments:

Post a Comment