logo
  • Home
  • Rank
  • Tests
  • About
  • Training
  • Programming
  • CS
  • IT
  • IS
  • ECE
  • EEE
  • EE
  • Civil
  • Mechanical
  • Chemical
  • Metallurgy
  • Instrumentation
  • Aeronautical
  • Aerospace
  • Biotechnology
  • Agriculture
  • MCA
  • BCA
  • Internship
  • Contact

JavaScript Multiple Choice Questions | MCQs | Quiz

Javascript Interview Questions and Answers
Practice Javascript questions and answers for interviews, campus placements, online tests, aptitude tests, quizzes and competitive exams.

Get Started

•   Lexical Structure
•   Types, Values & Variables
•   Expressions & Operators
•   Statements
•   JavaScript Loops
•   Object Attributes
•   Array & Related Methods
•   Invoking Functions
•   Functional Programming
•   Closures
•   JavaScript Classes
•   Augmentation of Classes
•   JavaScript Modules
•   Pattern Matching
•   JavaScript Subsets
•   JavaScript Extentions
•   Shorthand Functions
•   Server-Side JavaScript
•   Scripting Java - Rhino
•   Asynchronous I/O - Rhino
•   Client-Side JavaScript
•   Embedding JavaScript
•   JavaScript-Web Browsers-1
•   JavaScript-Web Browsers-2
•   Client-Side Frameworks
•   Document Object Model
•   Window Object
•   Error Handling - 1
•   Error Handling - 2
•   Scripting Documents
•   Scripting CSS
•   Handling Events
•   Mouse Events
•   Text Events
•   Drag & Drop Events
•   Keyboard Events
•   Node Operations - 1
•   Node Operations - 2
•   Cookies
•   Scripted HTTP
•   The jQuery Library
•   Client-Side Storage
•   Client-Side Databases
•   Scripted Media
•   Graphics
•   Browser Rendering - 1
•   Browser Rendering - 2
•   JavaScript Performance - 1
•   JavaScript Performance - 2
•   JavaScript - FireBug
•   JavaScript - YSlow
•   JavaScript - WebPagetest
•   JavaScript Minification - 1
•   JavaScript Minification - 2
•   Web Sockets
•   JavaScript History
•   Getting Started with R - 1
•   Getting Started with R - 2
•   Getting Started with R - 3
•   Enhanced JavaScript with R
•   WebPagetest API Access
•   Configuration File Creation
•   Parsing Values - 1
•   Parsing Values - 2
•   JavaScript Benchmarking-1
•   JavaScript Benchmarking-2
•   Public API Crafting
•   Remote Logging
•   Object Invocation
•   PerfLogger Performance
•   Navigation & Memory - 1
•   Navigation & Memory - 2
•   BottleNecks Optimization
•   Script Loading - 1
•   Script Loading - 2
•   Lazy Loading - 1
•   Lazy Loading - 2
•   Cache Variable & Properties
•   Closure Compiler
•   Web Workers
•   JavaScript Blobs
•   JavaScript & Memory Leak
•   External JavaScript & PHP
•   HTML APIs
•   HTML DOM
•   Animation
•   Validation
•   Image Map
•   Debugging Forms
•   JavaScript vs Frameworks-1
•   JavaScript vs Frameworks-2

JavaScript Tests

JavaScript Tests

Best Reference Books

Javascript Books
« Prev Page
Next Page »

JavaScript Questions & Answers – Modules in JavaScript

Posted on August 29, 2013 by Manish

This set of Javascript Multiple Choice Questions & Answers (MCQs) focuses on “Modules in JavaScript”.

1. The functions provide() and require() of Dojo toolkit and Google’s Closure library are used for
a) declaring and loading modules
b) declaring functions
c) declaring modules
d) loading modules
View Answer

Answer: a
Explanation: Both the Dojo toolkit and Google’s Closure library define provide() and require() functions for declaring and loading modules.
advertisement

2. The maximum number of global symbols a module can define is ____________
a) 2
b) 3
c) 1
d) 4
View Answer

Answer: c
Explanation: Generally, the various modules are allowed to run in the pristine (or near pristine) environment that it expects. The modules should minimize the number of global symbols they define – ideally, no module should define more than one.

3. To define each of the set classes as a property of the sets object (namespace) for the module, the statement is

a) sets = sets.AbstractEnumerableSet.extend();
b) sets.SingletonSet = sets.AbstractEnumerableSet.extend(...);
c) sets.SingletonSet = sets.extend(...);
d) sets = sets.extend(...);
View Answer
Answer: b
Explanation: Singleton is an object which can only be instantiated once.The extend keyword is used in class declarations or class expressions to create a class which is a child of another class. The sets object is the namespace for the module, and we define each of the set classes as a property of this object.
 
 

4. Consider the following statement

var Set = sets.Set;
var s = new Set(1,2,3);

What could be the efficiency quotient of the above two statements ?
a) The programmer imports at once the frequently used values into the global namespace
b) There is no efficiency quotient, the programmer tries to make it inefficient
c) The programmer needs to import the Sets everytime he wants to use it
d) the programmer imports the set everytime the statement is encountered
View Answer

Answer: a
Explanation: A programmer can import frequently used values into the global namespace. A programmer who was going to make frequent use of the Set class from the sets namespace might import the class like that.
advertisement

5. The scope of a function is also called as ________
a) Predefined function
b) Module function
c) Public function
d) Private function
View Answer

Answer: b
Explanation: The scope of a function can be used as a private namespace for a module. Therefore, the scope of a function is called a module function.

6. Modules that have more than one item in their API can ________
a) Assign itself to a global variable
b) Invoke another module of the same kind
c) Return a namespace object
d) Invoke another module of the same kind
View Answer

Answer: c
Explanation: Namespace is a container for set of identifiers, functions, methods and all that. It gives a level of direction to its contents so that it will be well distinguished and organized. Modules that have more than one item in their API can return a namespace object.

7. The provides() function and the exportsobject are used to _________
a) Register the module’s API and Store their API
b) Call the modules api
c) Store the module’s API
d) Register the modules api
View Answer

Answer: a
Explanation: Frameworks that define module loading systems may have other methods of exporting a module’s API. There may be a provides() function for modules to register their API, or an exports object into which modules must store their API.

8. What could be achieved by running the code snippet below?

var sets = com.davidflanagan.collections.sets;

a) Importing a single module
b) Importing a module partially
c) Importing a namespace
d) Importing the entire module
View Answer

Answer: d
Explanation: Rather than importing individual classes, a programmer might import the entire module to the global namespace.
advertisement

9. The properties() method is a ________
a) Enumerable method
b) Non-enumerable method
c) Operational method
d) calling method
View Answer

Answer: b
Explanation: The properties() is a method to get information of the properties of a particular object. properties() method is a non-enumerable method.

10. What can be done in order to avoid creation of global variables in JavaScript?
a) To use a method that defines all the variables
b) To use an object that has the reference to all the variables
c) To use an object as its namespace
d) To use global functions
View Answer

Answer: c
Explanation: One way for a module to avoid the creation of global variables is to use an object as its namespace. Instead of defining global functions and variables, it stores the functions and values as properties of an object (which may be referenced to a global variable).

Sanfoundry Global Education & Learning Series – Javascript Programming.

To practice all areas of Javascript, here is complete set of 1000+ Multiple Choice Questions and Answers on Javascript.
« Prev Page - JavaScript Questions & Answers – Augmentation of Classes
» Next Page - JavaScript Questions & Answers – Pattern Matching and Regular Expressions

« JavaScript Questions & Answers – Augmentation of Classes
JavaScript Questions & Answers – Pattern Matching and Regular Expressions »
advertisement

Deep Dive @ Sanfoundry:

  1. Java Programming Examples on Multithreading
  2. PHP Questions and Answers
  3. Java Programming Examples on Classes
  4. Object Oriented Programming Questions and Answers
  5. Ruby Programming Questions and Answers
  6. Java Programming Examples on Java.Lang
  7. Java Programming Examples on Inheritance
  8. C# Programming Examples on Functions
  9. Python Questions and Answers
  10. Javascript Questions and Answers
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer and SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage & Cluster Administration, Advanced C Programming, SAN Storage Technologies, SCSI Internals and Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him below:
LinkedIn | Facebook | Twitter | Google+

Best Careers

Developer Tracks
SAN Developer
Linux Kernel Developer
Linux Driver Developer
Linux Network Developer

Live Training Photos
Mentoring
Software Productivity
GDB Assignment
Sanfoundry is No. 1 choice for Deep Hands-ON Trainings in SAN, Linux & C, Kernel Programming. Our Founder has trained employees of almost all Top Companies in India such as VMware, Citrix, Oracle, Motorola, Ericsson, Aricent, HP, Intuit, Microsoft, Cisco, SAP Labs, Siemens, Symantec, Redhat, Chelsio, Cavium, ST-Micro, Samsung, LG-Soft, Wipro, TCS, HCL, IBM, Accenture, HSBC, Mphasis, Tata-Elxsi, Tata VSNL, Mindtree, Cognizant and Startups.

Best Trainings

SAN I - Technology
SAN II - Admin
Linux Fundamentals
Advanced C Training
Linux-C Debugging
System Programming
Network Programming
Linux Threads
Kernel Programming
Kernel Debugging
Linux Device Drivers

Best Reference Books

Computer Science Books
Algorithm & Programming Books
Electronics Engineering Books
Electrical Engineering Books
Chemical Engineering Books
Civil Engineering Books
Mechanical Engineering Books
Industrial Engineering Books
Instrumentation Engg Books
Metallurgical Engineering Books
All Stream Best Books

Questions and Answers

1000 C Questions & Answers
1000 C++ Questions & Answers
1000 C# Questions & Answers
1000 Java Questions & Answers
1000 Linux Questions & Answers
1000 Python Questions
1000 PHP Questions & Answers
1000 Hadoop Questions
Cloud Computing Questions
Computer Science Questions
All Stream Questions & Answers

India Internships

Computer Science Internships
Instrumentation Internships
Electronics Internships
Electrical Internships
Mechanical Internships
Industrial Internships
Systems Internships
Chemical Internships
Civil Internships
IT Internships
All Stream Internships

About Sanfoundry

About Us
Copyright
Terms
Privacy Policy
Jobs
Bangalore Training
Online Training
Developers Track
Mentoring Sessions
Contact Us
Sitemap
© 2011 Sanfoundry. All Rights Reserved.