0% found this document useful (0 votes)
534 views

JQuery MCQ (Awt)

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
534 views

JQuery MCQ (Awt)

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

jQuery MCQ (Multiple Choice Questions)

1) Who developed jQuery, and in which year it was first released?

a. John Richard in 2001


b. Mark Bensman in 2004
c. John Resig in 2006
d. None of the above

Hide Answer Workspace

Answer: (c) John Resig in 2006

Explanation: jQuery was first released in January 2006 by John Resig at BarCamp NYC.
It is currently headed by Timmy Wilson and maintained by a team of developers.

2) jQuery is a -

a. JavaScript method
b. JavaScript library
c. JSON library
d. PHP method

Hide Answer Workspace

Answer: (b) JavaScript library

Explanation: jQuery is a fast, small, cross-platform and feature-rich JavaScript library.


It is designed to simplify the client-side scripting of HTML. It is a small, light-weight
and fast JavaScript library.

3) Which of the following sign is used as a shortcut for jQuery?

a. the % sign
b. the & sign
c. the $ sign
d. the @ sign
Hide Answer Workspace

Answer: (c) the $ sign

Explanation: Every jQuery selector start with this dollar sign $(). This sign is known as
the factory function. It uses the three basic building blocks while selecting an element
in a given document.

4) $(this) in jQuery is used when -

PlayNext
Unmute

Current Time 0:00

Duration 18:10
Loaded: 0.37%
Â
Fullscreen
Backward Skip 10sPlay VideoForward Skip 10s

a. an HTML element references the entire document


b. an HTML element references its own action
c. an HTML element references the action of its parent element
d. All of the above

Hide Answer Workspace

Answer: (b) an HTML element references its own action

Explanation: $(this) and this refers to the same element. But they are used in a
different way. When 'this' is wrapped in $(), it becomes the jQuery object, and it is used
when an HTML element refers to its own action.

5) Which of the following jQuery method is used to hide the selected elements?

a. The hidden() method


b. The hide() method
c. The visible(false) method
d. The display(none) method

Hide Answer Workspace

Answer: (b) The hide() method

Explanation: The jQuery hide() method is used to hide the selected elements.

6) Which jQuery method is used to set one or more style properties to the selected
element?

a. The html() method


b. The style() method
c. The css() method
d. All of the above

Hide Answer Workspace

Answer: (c) The css() method

Explanation: The jQuery css() method is used to get (return) or set style properties or
values for selected elements. It facilitates you to get or set one or more style properties.

7) Which of the following jQuery method can be used to deal with the name conflicts?

a. The conflict() method


b. The nameConflict() method
c. The noConflict() method
d. None of the above

Hide Answer Workspace

Answer: (c) The noConflict() method

Explanation: Many JavaScript libraries also use the $ sign as the shortcut, along with
the jQuery on the same page. But if two different frameworks use the same alias, a
conflict could occur, and one of the frameworks might stop working. The noConflict()
method is implemented in jQuery to deal with such situations. It is used to avoid the
conflict of using $ variable with other libraries. This method releases the hold on the $
(dollar) identifier so that other libraries can use it.

8) The correct syntax to set the background color of all h1 elements to yellow in jQuery -

a. $("h1").style("background-color","yellow");
b. $("h1").html("background-color","yellow");
c. $("h1").css("background-color","yellow");
d. $("h1").layout("background-color","yellow");

Hide Answer Workspace

Answer: (c) $("h1").css("background-color","yellow");

Explanation: In jQuery, using the css() method, we can set the style of an HTML
element. The correct syntax for setting the background color to yellow of an h1
element is - $("h1").css("background-color","yellow");

9) Which of the following jQuery method is used to attach a handler to an event?

a. unbind() method
b. attach() method
c. bind() method
d. None of the above

Hide Answer Workspace

Answer: (c) bind() method

Explanation: The jQuery bind() event is used to attach one or more event handlers for
selected elements from a set of elements. It specifies a function to run when the event
occurs.

10) The jQuery method used to perform an asynchronous HTTP request -

a. jQuery ajaxSetup() method


b. jQuery ajaxSync() method
c. jQuery ajax() method
d. None of the above

Hide Answer Workspace

Answer: (c) jQuery ajax() method

Explanation: AJAX is an acronym for Asynchronous JavaScript and XML. The ajax()
method in jQuery performs an AJAX request. It sends an asynchronous HTTP request
to the server.

11) Which of the following jQuery method is used to stop jQuery for few milliseconds?

a. stop() method
b. delay() method
c. slowdown() method
d. pause() method

Hide Answer Workspace

Answer: (b) delay() method

Explanation: The jQuery delay() method is used to delay the execution of functions in
the queue. It is the best method to make a delay between the queued jQuery effects.
The jQuery delay() method sets a timer to delay the execution of the next item in the
queue.

12) What does the syntax $("p.para") will select?

a. The first paragraph element with class = "para"


b. The first paragraph element with id = "para"
c. The first paragraph element with name = "para"
d. All paragraph elements with class = "para"

Hide Answer Workspace

Answer: (d) All paragraph elements with class = "para"


Explanation: In jQuery, the correct syntax for selecting all paragraph elements with
class = "para" is - $("p.para").

13) Which of the jQuery function prevents the code from running before the loading of
the document finishes?

a. $(document).load()
b. $(document).unload()
c. $(document).ready()
d. $(document).trim()

Hide Answer Workspace

Answer: (c) $(document).ready()

Explanation: The ready() function in jQuery executes the code only when the DOM
(Document object model) is fully loaded. The code inserted between
$(document).ready() is executed only when a page is ready for JavaScript code to
execute.

14) The jQuery used to find all next sibling elements after the current element is -

a. find() method
b. nextAll() method
c. siblings() method
d. None of the above

Hide Answer Workspace

Answer: (b) nextAll() method

Explanation: The nextAll() method is used to return all next siblings of the specified
selector. This method traverses forwards along with the next siblings of DOM elements.
Whereas the siblings() method returns all next and previous siblings of the specified
selector.

15) The correct syntax for selecting the first paragraph element with id p1 is -
a. $("p.p1:first")
b. $("p#p1:first")
c. $("p1#p:first")
d. None of the above

Hide Answer Workspace

Answer: (b) $("p#p1:first")

Explanation: In jQuery, the correct syntax for selecting the first paragraph element
with id = "p1" is - $("p#p1:first").

16) Which of the following jQuery method is used to check whether or not the selected
elements have the specified class name?

a. hasClass() method
b. addClass() method
c. find() method
d. toggleClass() method

Hide Answer Workspace

Answer: (a) hasClass() method

Explanation: The jQuery hasClass() method is used to check whether selected


elements have a specified class name or not. It returns TRUE if the specified class is
present in any of the selected elements; otherwise, it returns FALSE.

17) Which of the following jQuery method is used to set the value of an element?

a. val() method
b. setValue() method
c. content() method
d. None of the above

Hide Answer Workspace

Answer: (a) val() method


Explanation: There are two usages of the jQuery val() method. It can be used to set
the value of every matched element. It can also be used to get the current value of the
first element in the set of matched elements.

18) The jQuery method used to set the width property of an element is -

a. setWidth( val ) method


b. width( val ) method
c. setCSSWidth( val ) method
d. None of the above

Hide Answer Workspace

Answer: (b) width( val ) method

Explanation: jQuery width() method is used to return or set the width of the matched
element. When this method is used to return the width, it returns the width of the first
matched element. When this method is used to set the width, it sets the width for every
matched element.

19) The jQuery method used to get all ancestors of the matched set of elements is -

a. parents() method
b. parent() method
c. offsetParent() method
d. None of the above

Hide Answer Workspace

Answer: (a) parents() method

Explanation: The parents() method in jQuery is used to get all ancestor elements of
the given selector. This method traverses upwards from the parent element, all the
level up in the DOM tree and returns all ancestors of the selected element.

20) The jQuery method used to remove the set of matched elements is -
a. delete() method
b. empty() method
c. remove() method
d. None of the above

Hide Answer Workspace

Answer: (c) remove() method

Explanation: The jQuery remove() method is used to remove the selected elements
out of the DOM. It removes the selected element itself, as well as everything inside it
(including all texts and child nodes). This method also removes the data and the events
of the selected elements.

21) The jQuery method used for parsing the JSON text is -

a. parseJSON() method
b. parseHTML() method
c. noConflict() method
d. each() method

Hide Answer Workspace

Answer: (a) jQuery.parseJSON() method

Explanation: The jQuery parseJSON() method takes a JSON string and returns a
JavaScript object. The specified JSON string must follow the strict JSON format. Passing
an incorrect string will cause a JS exception.

22) What does the syntax $("div#myDiv .para") will select?

a. It will select all elements with class = "para" within the div element with id =
"myDiv"
b. It will select all elements with id = "myDiv" within the div element with class =
"para"
c. All div elements with class = "para" or with id = "myDiv"
d. None of the above
Hide Answer Workspace

Answer: (a) It will select all elements with class = "para" within the div element with id
= "myDiv"

Explanation: The jQuery syntax $("div#myDiv .para") will select all elements with class
= "para" within the div element with id = "myDiv".

23) Which of the following jQuery method is used to reduce the set of matched elements
to a single element?

a. isEqual() method
b. val() method
c. eq() method
d. delegate() method

Hide Answer Workspace

Answer: (c) eq() method

Explanation: The eq() method in jQuery returns an element with the given index. This
method reduces the set of elements to the one with a specific index. The index can
either be positive or negative.

24) The toggle() method in jQuery is used to -

a. toggle between the hide() and show() methods


b. toggle between the fadeIn() and fadeOut() methods
c. toggle between the slideUp() and slideDown() methods
d. None of the above

Hide Answer Workspace

Answer: (a) toggles between the hide() and show() methods

Explanation: The jQuery toggle() is a special type of method which is used to toggle
between the hide() and show() method. It shows the hidden elements and hides the
shown element.
25) Which of the following method is used to toggle between the fadeIn() method and
fadeOut() method?

a. toggle() method
b. fadeToggle() method
c. slideToggle() method
d. animate() method

Hide Answer Workspace

Answer: (b) fadeToggle() method

Explanation: jQuery fadeToggle() method is used to toggle between the fadeIn() and
fadeOut() methods. If the elements are faded in, it will make them faded out, and if
they are faded out, it will make them faded in.

26) The :even and :odd filters in jQuery are used to -

a. determine if the number is odd or even


b. determine if the index position of an element is odd or even
c. both (a) & (b)
d. None of the above

Hide Answer Workspace

Answer: (b) determine if the index position of an element is odd or even

Explanation: The :even selector in jQuery is used to select the elements with even
index numbers (such as 2, 4, 6, etc.). The index starts at 0. The :odd selector in jQuery
is used to select the elements with an odd index number (such as 1, 3, 5, etc.).

27) If the names of variables are the same, then which of the following type of variable
takes precedence?

a. local variable
b. global variable
c. both (a) & (b)
d. None of the above

Hide Answer Workspace

Answer: (a) local variable

Explanation: In the function's body, the precedence of the local variable is more than
the global variable with the same name. If the name of the function's local variable is
the same as the name of the global variable, then the local variable hides the global
variable.

28) Which of the following is the correct code in jQuery to make all div elements 150px
high?

a. $("div").height(150);
b. $("div").height = "150" ;
c. $("div").height = 150 ;
d. None of the above

Hide Answer Workspace

Answer: (a) $("div").height(150);

Explanation: The jQuery height() method is used to set the height of every matched
element or return the current computed height for the first element. When it is used
to set the height, then it will set the height of every matched element, and when it is
used to return the height, the height() method will return the height of the first
matched element.

29) Which of the following is the basic requirement to start with jQuery?

a. To use jQuery, first, we have to buy the jQuery library from its official website.
b. To use jQuery, we don't require anything as it is already built in the browser we
are using.
c. To use jQuery, we have to refer to its hosted library, or we can download the
latest jQuery version from its official website.
d. All of the above
Hide Answer Workspace

Answer: (c) To use jQuery, we have to refer to its hosted library, or we can download
the latest jQuery version from its official website.

Explanation: To start with jQuery, we need to refer to its library, or we can download
the latest version of jQuery from jQuery.com.

30) CDN stands for -

a. Content development network


b. Content delivery network / Content distribution network
c. Communication development network
d. None of the above

Hide Answer Workspace

Answer: (b) Content delivery network / Content distribution network

Explanation: CDN stands for Content Delivery Network or Content Distribution


Network. It is a large distributed system of servers deployed in multiple data centers
across the internet. It provides the files from servers at a higher bandwidth that leads
to faster loading time.

31) The jQuery method used to find all previous sibling elements of the current element
is -

a. nextAll() method
b. prevAll() method
c. siblings() method
d. None of the above

Hide Answer Workspace

Answer: (b) prevAll() method

Explanation: The prevAll() method is jQuery's inbuilt function that returns all previous
siblings of the selected element. This method traverses backward along with the
previous siblings of DOM elements. Whereas the siblings() method returns all next and
previous siblings of the specified selector.

32) The jQuery method used to return the direct parent element of the selected element
is -

a. parents() method
b. parent() method
c. offsetParent() method
d. None of the above

Hide Answer Workspace

Answer: (b) parent() method

Explanation: The parent() method in jQuery finds the direct parent of the given
selector. It is an inbuilt function in jQuery. This method only traverses a single level up
in the DOM tree and returns the direct parent of the selected element.

33) The jQuery method used to load data using HTTP get is -

a. get(URL, data, callback, dataType) method


b. post(URL, data, callback, dataType) method
c. ajax() method
d. ajaxSend() method

Hide Answer Workspace

Answer: (a) get(URL, data, callback, dataType) method

Explanation: The get() method is an inbuilt function in jQuery. It loads data from the
server using the HTTP GET request. It is used for making a simple GET request. It returns
XMLHttpRequest object.

34) Can we use multiple document.ready() function on the same page?

a. Yes
b. No
c. Can't say
d. Not possible

Hide Answer Workspace

Answer: (a) Yes

Explanation: We can use any number of document.ready() function on the same page.
For example:

$(document).ready(function() {
$("h1").css("background-color", "red");
});

$(document).ready(function() {
$("p").css("background-color", "pink");
});

35) The code $("p").css("background-color","yellow") is equivalent to -

a. jQuery("p").css("background-color","yellow")
b. document("p").css("background-color","yellow")
c. jq("p").css("background-color","yellow")
d. None of the above

Hide Answer Workspace

Answer: (a) jQuery("p").css("background-color","yellow")

Explanation: Instead of using the $ (dollar sign), we can use jQuery as a function name.
For example:

jQuery(document).ready(function() {
jQuery("p").css("background-color", "yellow");
});

36) Which of the following jQuery method is used to add/remove one or more classes
from the selected elements?

a. toggleClass() method
b. fadeToggle() method
c. toggle() method
d. slideToggle() method

Hide Answer Workspace

Answer: (a) toggleClass() method

Explanation: The jQuery toggleCLass() method is used to add or remove one or more
classes from the selected elements. This method toggles between adding and
removing one or more class name. It checks each element for the specified class
names. If the class name is already set, it removes, and if the class name is missing, it
adds.

37) What does the syntax $("p") will select?

a. All paragraph elements


b. Only first paragraph element
c. Only last paragraph element
d. None of the above

Hide Answer Workspace

Answer: (a) All paragraph elements

Explanation: In jQuery, the syntax $("p") will select all paragraph elements.

38) What does the syntax $("p span") will select?

a. All span elements inside the paragraph element


b. Only first span element inside the paragraph element
c. Only last span element inside the paragraph element
d. None of the above

Hide Answer Workspace

Answer: (a) All span elements inside the paragraph element

Explanation: In jQuery, the syntax $("p span") will select all span elements inside a
paragraph element.
39) The selector $(":disabled") will select -

a. The elements with the text ":disabled"


b. The elements that do not include the text ":disabled"
c. The hidden elements
d. All disabled input elements

Hide Answer Workspace

Answer: (d) All disabled input elements

Explanation: The :disabled selector is used to select all disabled form elements. It is a
pseudo-class selector that can also be used to style the disabled UI elements. This
selector can only be used for the HTML elements that support the disabled attribute.

40) Which of the following selector in jQuery is used to select the elements with lesser
index value than the value of its index parameter?

a. jQuery :lt() selector


b. jQuery :gt() selector
c. jQuery :lang() selector
d. jQuery :nth-child selector

Hide Answer Workspace

Answer: (a) jQuery :lt() selector

Explanation: The :lt() selector selects the elements that have lesser index value than
the value specified in the index parameter of the :lt() selector. The index starts at 0.

41) Which of the following method in jQuery is used to make copies of the set of matched
elements?

a. jQuery detach() method


b. jQuery delegate() method
c. jQuery clone() method
d. jQuery serialize() method

Hide Answer Workspace

Answer: (c) jQuery clone() method

Explanation: The jQuery clone() method is used to make copies of the set of matched
elements. It also makes copies of their child nodes, texts and attributes. The clone()
method is a convenient way to duplicate elements on a page.

42) The jQuery method which is used to remove the tabs, space and the line breaks from
the beginning and end of the specified string is -

a. jQuery empty() method


b. jQuery trim() method
c. jQuery remove() method
d. jQuery serialize() method

Hide Answer Workspace

Answer: (b) jQuery trim() method

Explanation: The trim() method in jQuery is used to remove the space, tabs, and all
line breaks from the starting and end of the specified string. This method does not
remove these characters if these whitespace characters are in the middle of the string.

43) Which of the following jQuery method returns the direct children of the selected
element?

a. jQuery ancestors() method


b. jQuery next() method
c. jQuery children() method
d. None of the above

Hide Answer Workspace

Answer: (c) jQuery children() method


Explanation: The children() method in jQuery returns the direct children of the given
selector. It is an inbuilt method in jQuery.

44) Which of the following jQuery method returns all siblings of the selected element?

a. jQuery ancestors() method


b. jQuery siblings() method
c. jQuery parents() method
d. None of the above

Hide Answer Workspace

Answer: (b) jQuery siblings() method

Explanation: As its name implies, the siblings() method returns all siblings of the
selected element. It is an inbuilt method in jQuery.

45) The jQuery selector used to select the elements containing the specified string is -

a. jQuery :contains selector


b. jQuery :lang() selector
c. jQuery :nth-child selector
d. None of the above

Hide Answer Workspace

Answer: (a) jQuery :contains selector

Explanation: The :contains() selector in jQuery selects the elements that contain the
specified string. The matching string can be directly appeared in the selected element
or in the descendants of that element.

46) The jQuery selector used to select the elements with the specified language code is -

a. jQuery :contains selector


b. jQuery :lang() selector
c. jQuery :nth-child selector
d. None of the above

Hide Answer Workspace

Answer: (b) jQuery :lang() selector

Explanation: The :lang() selector is used to select the elements with the specified
language code. It selects the elements whose language value is equal to the supplied
language code. We can use the lang attribute in HTML to determine the language
value of the elements.

47) Which of the following jQuery method is used to replace all selected elements with
new HTML elements?

a. jQuery replaceWith() method


b. jQuery replaceAll() method
c. jQuery load() method
d. jQuery delegate() method

Hide Answer Workspace

Answer: (b) jQuery replaceAll() method

Explanation: The replaceAll() method in jQuery replaces all selected elements with
new HTML elements. This method replaces the elements and their contents with other
HTML elements. It returns the selected elements with new content.

48) The jQuery method used to trigger a specified event handler for the selected element
is -

a. jQuery trigger() method


b. jQuery toggle() method
c. jQuery eq() method
d. jQuery next() method

Hide Answer Workspace


Answer: (a) jQuery trigger() method

Explanation: The trigger() method is used to trigger the specified event handler for
every matched element. This method can also be used to trigger the default behavior
for the selected elements.

49) Which of the following method is used to remove the specified attribute from the
selected element?

a. jQuery remove() method


b. jQuery empty() method
c. jQuery removeAttr() method
d. jQuery error() method

Hide Answer Workspace

Answer: (c) jQuery removeAttr() method

Explanation: The removeAttr() method is used to remove attributes from the element.
This method is used to remove the specified attribute from the selected element.

50) Which of the following jQuery method is used to merge the content of two or more
objects into the first object?

a. jQuery extend() method


b. jQuery eq() method
c. jQuery data() method
d. jQuery param() method

Hide Answer Workspace

Answer: (a) jQuery extend() method

Explanation: The jQuery extend() method together merges the content of two or
more objects into the first object. This method returns the merged object.
Node.js MCQ
1) Which of the following statement is correct?

a. js is Server Side Language.


b. js is the Client Side Language.
c. js is both Server Side and Client Side Language.
d. None of the above.

Hide Answer Workspace

Answer: A is the correct option. Node.js is Server Side Language.

2) What does the REPL stand for?

a. REPL stands for "Read Eval Print Loop."


b. REPL stands for "Research Eval Program Learn."
c. REPL stands for "Read Earn Point Learn."
d. REPL stands for "Read Eval Point Loop."

Hide Answer Workspace

Answer: A is the correct option. REPL stands for "Read Eval Print Loop".

3) Which of the following command is used to start a REPL session?

a. $ node
b. $ node start
c. $ node repl
d. $ node console

Hide Answer Workspace

Answer: A is the correct option. We can start REPL simply by running node on
shell/console without any argument.
4) In which language is Node.js written?

PlayNext

Unmute

Current Time 0:17

Duration 18:10

Loaded: 6.24%
Â

Fullscreen

Backward Skip 10sPlay VideoForward Skip 10s

a. JavaScript
b. C
c. C++
d. CoffeeScript
e. All of the above

Hide Answer Workspace

Answer: E is the correct option. Node.js is a cross-platform, back-end JavaScript


runtime environment written in JavaScript, C, C++, and CoffeeScript language.

5) Which of the following command is used to install the Node.js express module?

a. $ npm install express


b. $ node install express
c. $ install express
d. None of the above

Hide Answer Workspace


Answer: A is the correct option. The $ npm install express command is used to install
the Node.js express module.

6) What is Callback?

a. The callback is a technique in which a method calls back the caller method.
b. The callback is an asynchronous equivalent for a function.
c. Both of the above.
d. None of the above.

Hide Answer Workspace

Answer: B is the correct option. The callback is an asynchronous equivalent for a


function.

7) Which of the following extension is used to save the Node.js files?

a. .js
b. .node
c. .java
d. .txt

Hide Answer Workspace

Answer: A is the correct option. The ".js" extension is used to save the Node.js files.

8) The Node.js modules can be exposed using:

a. expose
b. module
c. exports
d. All of the above

Hide Answer Workspace


Answer: C is the correct option. The Node.js modules can be exposed using
module.exports.

9) Which of the following module is not a built-in node module?

a. zlib
b. https
c. dgram
d. fsread

Hide Answer Workspace

Answer: D is the correct option. The "fsread" is not a built-in node module.

10) Which of the following method of fs module is used to get file information?

a. fs.open(path, flags[, mode], callback)


b. fs.stat(path, callback)
c. fs.readFile(path, flags[, mode], callback)
d. None of the above.

Hide Answer Workspace

Answer: B is the correct option. The fs.stat(path, callback) method is used to get
information about a file.

11) What does the fs module stand for?

a. File Service
b. File System
c. File Store
d. File Sharing

Hide Answer Workspace

Answer: B is the correct option. The fs module stands for File System.
12) Which of the following method of fs module is used to truncate a file?

a. fs.delete(fd, len, callback)


b. fs.remove(fd, len, callback)
c. fs.ftruncate(fd, len, callback)
d. None of the above.

Hide Answer Workspace

Answer: C is the correct option. The fs.ftruncate(fd, len, callback) method is used to
truncate a file.

13) Which of the following template engines can be used with Node.js?

a. Jade
b. Vash
c. Handlebars
d. All of the above

Hide Answer Workspace

Answer: C is the correct option. Handlebars are the template engines that can be used
with Node.js.

14) Which of the following code print the platform of operating system?

a. console.log('platform : ' + os.platform);


b. console.log('platform : ' + os.platform());
c. console.log('platform : ' + os.getPlatform());
d. None of the above.

Hide Answer Workspace

Answer: B is the correct option. The os.platform() returns the operating system
platform.
15) Which of the following method is used to return the current working directory of the
process?

a. cwd();
b. cwd();
c. pwd();
d. None of the above.

Hide Answer Workspace

Answer: A is the correct option. The process.cwd() method is used to return the
current working directory of the process.

16) Which of the following statement defines Express?

a. Express is an application framework that provides a robust set of features to develop


desktop-based applications.
b. Express is a minimal and flexible Node.js web application framework that provides a
robust set of features to develop web and mobile applications.
c. Both of the above.
d. None of the above.

Hide Answer Workspace

Answer: B is the correct option. Express is a minimal and flexible Node.js web
application framework that provides a robust set of features to develop web and
mobile applications.

17) Which of the following is not a benefit of using modules in Express?

a. It provides a means of dividing up tasks.


b. It provides a means of reuse of program code.
c. It provides a means of reducing the size of the program.
d. It provides a means of testing individual parts of the program.
Hide Answer Workspace

Answer: C is the correct option. "It provides a means of reducing the size of the
program" is not a benefit of modules in Express.

18) What is the best practice to do in your code to improve the performance of your
application?

a. Using gzip compression.


b. Don't use synchronous functions.
c. Do logging correctly.
d. Handle exceptions properly.

Hide Answer Workspace

Answer: A is the correct option. Using gzip compression is the best practice to do in
your code to improve the performance of your application.

19) What is the default scope in the Node.js application?

a. Global
b. Local
c. Global Function
d. Local to object

Hide Answer Workspace

Answer: B is the correct option. Local is the default scope in the Node.js application.

20) Which of the following engine Node in core?

a. Chrome V8
b. Microsoft Chakra
c. SpiderMonkey
d. Node En
Hide Answer Workspace

Answer: A is the correct option. Node uses the Chrome V8 engine in the core.

21) Which of the following statement is used to execute the code of the sample.js file?

a. sample.js
b. node sample.js
c. nodejs sample.js
d. None of the above.

Hide Answer Workspace

Answer: B is the correct option. The "node sample.js" statement is used to execute the
code of the sample.js file.

22) Which of the following is not a valid language for Node.js?

a. JavaScript
b. Java
c. C
d. C++

Hide Answer Workspace

Answer: B is the correct option. Java is not a valid language for Node.js.

23) Which of the following shortcut command is used to kill a process in Node.js?

a. Ctrl + B
b. Ctrl + K
c. Ctrl + T
d. Ctrl + C

Hide Answer Workspace


Answer: D is the correct option. The Ctrl + C command is used to kill a process in
Node.js.

24) How many Node object methods are available?

a. 21
b. 18
c. 19
d. 20

Hide Answer Workspace

Answer: B is the correct option. There are 18 object methods available in Node.

25) What is the main usage of Node.js terminal (REPL)?

a. To specify the preview of the Node.js application.


b. For testing Node.js/JavaScript expressions.
c. For executing browser's JavaScript expressions.
d. None of the above.

Hide Answer Workspace

Answer: B is the correct option. The Node.js terminal (REPL) is used for testing
Node.js/JavaScript expressions.

26) Which of the following types of applications can be built using Node.js?

a. Web Application
b. Chat Application
c. RESTful Service
d. All of the above

Hide Answer Workspace


Answer: D is the correct option. All of the above types of applications can be built by
using Node.js.

27) Which of the following is used to test if two nodes are equal?

a. ==
b. equal()
c. isEqualNode()
d. None of the above.

Hide Answer Workspace

Answer: C is the correct option. The "isEqualNode()" is used to test if two nodes are
equal.

28) Which of the following tool is used to automate the various tasks of the Node.js
application?

a. Express.js
b. GruntJS
c. NPM
d. None of the above

Hide Answer Workspace

Answer: B is the correct option. GruntJS tool is used to automate the various tasks of
the Node.js application.

29) Which of the following areas, Node.js, is not advised to be used?

a. Single Page Applications


b. JSON APIs based Applications
c. CPU intensive applications
d. Data-Intensive Real-time Applications (DIRT)

Hide Answer Workspace


Answer: C is the correct option. It is not advisable to use Node.js for CPU-intensive
applications.

30) Which of the following route parameter formats are valid?

a. /books/!:from-:to
b. /flights/:from-:to
c. /users/:userId/books/:bookId
d. None of the above.

Hide Answer Workspace

Answer: A is the correct option.

31) Which of the following module is required to create a web server?

a. net module
b. http module
c. net module
d. url module

Hide Answer Workspace

Answer: D is the correct option. The url module is required to create a web server.

32) Which of the following is the correct syntax to initiate the Node.js File?

a. filename.js
b. javascript filename.js
c. node filename.js
d. node filename

Hide Answer Workspace

Answer: C is the correct option. The correct syntax to initiate the Node.js File is node
filename.js.
33) Which of the following method is used to compare the placement of two nodes in the
DOM hierarchy (document)?

a. cloneNode()
b. compareDocumentPosition()
c. getFeature()
d. getUserData()

Hide Answer Workspace

Answer: B is the correct option. The compareDocumentPosition()method compares


the placement of two nodes in the DOM hierarchy (document).

34) Which of the following platforms does Node.js support?

a. Windows
b. Macintosh
c. Unix/Linux
d. All of the above.

Hide Answer Workspace

Answer: D is the correct option. Node.js is supported on all of the above written
operating systems.

35) Which of the following keyword is used to make properties and methods available
outside the module file?

a. import
b. module
c. exports
d. require

Hide Answer Workspace


Answer: C is the correct option. The exports keyword is used to make properties and
methods available outside the module file.

36) Which of the following Node.js object property is used to return the node immediately
before a node?

a. localName
b. index
c. previousSibling
d. textContent

Hide Answer Workspace

Answer: C is the correct option. The previousSibling object property is used to return
the node immediately before a node.

37) Which of the following method can append specified content to a file?

a. fs.appendFile()
b. fs.open()
c. fs.writeFile()
d. None of the above.

Hide Answer Workspace

Answer: A is the correct option. The fs.appendFile() method is used to append the
specified content to a file. If the file does not exist, it creates the file.

38) Which of the following is a GUI-based debugging tool for Node.js?

a. Core node debugger


b. Console
c. REPL
d. Node Inspector

Hide Answer Workspace


Answer: D is the correct option. Node Inspector is a GUI-based debugging tool for
Node.js.

39) What is the use of underscore variable in REPL session in Node.js?

a. It is used to store the result.


b. It is used to get the last command used.
c. It is used to get the last result.
d. None of the above.

Hide Answer Workspace

Answer: C is the correct option. In Node.js, the underscore variable in REPL session is
used to get the last result.

True or False Questions


40) The buffer class is a global class that can be accessed without importing a buffer
module.

a. True
b. False

Hide Answer Workspace

Answer: True. A is the correct option. A buffer class is a global class that can be
accessed in the application without importing a buffer module.

41) Is Node.js multithreaded?

a. Yes
b. No

Hide Answer Workspace

Answer: No. B is the correct option. Node.js is not multithreaded.


42) Is the process a global object and can be accessed from anywhere?

a. True
b. False

Hide Answer Workspace

Answer: True. A is the correct option. The process object is a global object and can be
accessed from anywhere.

43) Node.js uses an event-driven, non-blocking I/O model. Is it true?

a. True
b. False

Hide Answer Workspace

Answer: True. A is the correct option. Node.js uses an event-driven, non-blocking I/O
model.

44) The net.isIP(input) returns 0 for invalid input. Is it true?

a. True
b. False

Hide Answer Workspace

Answer: True. A is the correct option. The net.isIP(input) tests if input is an IP address.
It returns 0 for invalid strings, returns 4 for IP version 4 addresses, and returns 6 for IP
version 6 addresses.

45) A stream fires finish event when all data has been flushed to the underlying system. Is
it true?

a. True
b. False

Hide Answer Workspace


Answer: True. A is the correct option.

46) A stream fires data event when there is data available to read. Is it true?

a. True
b. False

Hide Answer Workspace

Answer: True. A is the correct option. A stream fires data event when there is data
available to read.

MONGO DB

You might also like