Java MCQ Set 1
1. What is the purpose of minifying the JavaScript?
a) To streamline the visits
b) To save the visits
c) All of the mentioned
d) None of the mentioned
Answer
Answer: a [Reason:] To ensure that our first-time visits are as streamlined as possible, we need to minify our JavaScript.
2. From which did Minification concept originate?
a) JavaScript code efficiency
b) JavaScript interpreter
c) Both JavaScript code efficiency and interpreter
d) None of the mentioned
Answer
Answer: b [Reason:] Minification is originally based on the idea that the JavaScript interpreter ignores white space, line breaks, and of course comments, so we can save on total file size of our .js files if we remove those unneeded characters.
3. What is the purpose of the product Minify?
a) Storing the data
b) Streamlining the data
c) Proxies the JavaScript file
d) All of the mentioned
Answer
Answer: c [Reason:] Minify proxies the JavaScript file;the script tag on the page points to Minify, which is a PHP file.
4. What does the Minify set the encoding HTTP header?
a) deflate
b) gzip
c) both deflate and gzip
d) none of the mentioned
Answer
Answer: c [Reason:] Minify reads the JavaScript file in, minifies it and when it responds it sets the accept encoding HTTP header to gzip, deflate.
5. What is in-built in the Minify?
a) Dynamic compression
b) Static compression
c) Static content
d) None of the mentioned
Answer
Answer: b [Reason:] Effectively Minify has built in HTTP static compression. This is especially useful if your web host doesn’t allow the gzipping of static content.
6. Which folder contains the Minify control panel?
a) /min/builder/
b) /builder/
c) /minify/build
d) /minify/builder
Answer
Answer: a [Reason:] To navigate to the Minify control panel, it is located in the /min/builder/.
7. Which of the following is the order of Minify process?
a) Remove extraneous characters, gzip the response, Read
b) Remove extraneous characters, Read, gzip the response
c) Read, Remove extraneous characters, gzip the response
d) None of the mentioned
Answer
Answer: c [Reason:] Minify reads in the content, decorates it by way of removing extraneous characters, and gzips the response.
8. YUI Compressor is analogous to
a) Minify
b) JavaScript
c) Both Minify and JavaScript
d) None of the mentioned
Answer
Answer: a [Reason:] Just like Minify, YUI Compressor strips out all of the unnecessary characters from your JavaScript, including spaces, line breaks, and comments.
9. What type of file is YUI Compressor?
a) Binary file
b) JAR file
c) Text file
d) Assembly file
Answer
Answer: b [Reason:] YUI Compressor is a jar file and runs from the command line. Because of this it is easily integrated into a build process. It looks like this:
java -jar yuicompressor-[version].jar [options] [file name]
10. What is the function of a Closure Compiler?
a) Originates the JavaScript
b) Compiles the JavaScript
c) Rewrites JavaScript
d) None of the mentioned
Answer
Answer: c [Reason:] Closure Compiler runs through a number of “scorched-earth” optimizations—it unfurls functions, rewrites variable names, and removes functions that are never called (as far as it can tell).
Java MCQ Set 2
1. The functions provide() and require() of Dojo toolkit and Google’s Closure library are used for
a) declaring and loading modules
b) loading and declaring modules
c) declaring modules
d) none of the mentioned
Answer
Answer: a [Reason:] Both the Dojo toolkit and Google’s Closure library define provide() and require() functions for declaring and loading modules.
2. The maximum number of global symbols a module can define is
a) 2
b) 3
c) 1
d) 4
Answer
Answer: c [Reason:] 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(...);
Answer
Answer: b [Reason:] 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) All of the mentioned
Answer
Answer: a [Reason:] 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.
5. The scope of a function is also called as
a) The function’s scope
b) Module function
c) Modulated function
d) Private function
Answer
Answer: b [Reason:] 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
Answer
Answer: c [Reason:] 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) Store the module’s API and register their API
c) Store the module’s API
d) None of the mentioned
Answer
Answer: a [Reason:] 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. Consider the following code snippet
var sets = com.davidflanagan.collections.sets;
What is the programmer trying to do in the above code snippet?
a) Importing a single module
b) Importing a module partially
c) Importing a namespace
d) Importing the entire module
Answer
Answer: d [Reason:] Rather than importing individual classes, a programmer might import the entire module to the global namespace.
9. The properties() method is a
a) Enumerable method
b) Non-enumerable method
c) Operational method
d) None of the mentioned
Answer
Answer: b [Reason:] The 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
Answer
Answer: c [Reason:] 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).
Java MCQ Set 3
1. How many node types are there in total?
a) 11
b) 12
c) 13
d) 14
Answer
Answer: b [Reason:] There are total of 12 node types.
2. What is the purpose of the Node object property ownerDocument?
a) Returns the root element
b) Returns the last element
c) Returns the parent node
d) Returns the immediate node
Answer
Answer: a [Reason:] The node object property ownerDocument returns the root element (document object) for a node.
3. Which of the following Node object property returns the local part of the name of a node?
a) lastName
b) localName
c) firstName
d) none of the mentioned
Answer
Answer: b [Reason:] The Node object property localName Returns the local part of the name of a node
4. What is the property textContent?
a) Sets the textual content of a node
b) Returns the textual content of a node
c) Sets & Returns the textual content of a node
d) None of the mentioned
Answer
Answer: c [Reason:] The property textContent sets or returns the textual content of a node and its descendants.
5. How many Node object methods are available?
a) 18
b) 19
c) 20
d) 21
Answer
Answer: a [Reason:] There are totally 18 node object methods.
6. Which of the following Node object property returns the node immediately before a node?
a) previousSibling
b) textContent
c) index
d) localName
Answer
Answer: a [Reason:] The node object property previousSibling returns the node immediately before a node.
7. What is the purpose of the method getUserData(key)?
a) Returns the associated object
b) Gets the user data
c) Returns the user data
d) None of the mentioned
Answer
Answer: a [Reason:] The method getUserData(key) returns the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key.
8. How to test if two nodes are equal?
a) isEqualNode()
b) equal()
c) ==
d) none of the mentioned
Answer
Answer: a [Reason:] The method isEqualNode() is used to test if two nodes are equal.
9. How to associate an object to a key on a node?
a) getUserData()
b) cloneNode()
c) setUserData(key,data,handler)
d) none of the mentioned
Answer
Answer: c [Reason:] The method setUserData(key,data,handler) is used to associate an object to a key on a node.
10. Which method is used to compare the placement of two nodes in the DOM hierarchy (document)?
a) compareDocumentPosition()
b) cloneNode()
c) getUserData()
d) getFeature()
Answer
Answer: a [Reason:] The compareDocumentPosition() method is used to compare the placement of two nodes in the DOM hierarchy (document).
Java MCQ Set 4
1. How many node types are there in total?
a) 11
b) 12
c) 13
d) 14
Answer
Answer: b [Reason:] There are total of 12 node types.
2. What is the purpose of the Node object property ownerDocument?
a) Returns the root element
b) Returns the last element
c) Returns the parent node
d) Returns the immediate node
Answer
Answer: a [Reason:] The node object property ownerDocument returns the root element (document object) for a node.
3. Which of the following Node object property returns the local part of the name of a node?
a) lastName
b) localName
c) firstName
d) none of the mentioned
Answer
Answer: b [Reason:] The Node object property localName Returns the local part of the name of a node
4. What is the property textContent?
a) Sets the textual content of a node
b) Returns the textual content of a node
c) Sets & Returns the textual content of a node
d) None of the mentioned
Answer
Answer: c [Reason:] The property textContent sets or returns the textual content of a node and its descendants.
5. How many Node object methods are available?
a) 18
b) 19
c) 20
d) 21
Answer
Answer: a [Reason:] There are totally 18 node object methods.
6. Which of the following Node object property returns the node immediately before a node?
a) previousSibling
b) textContent
c) index
d) localName
Answer
Answer: a [Reason:] The node object property previousSibling returns the node immediately before a node.
7. What is the purpose of the method getUserData(key)?
a) Returns the associated object
b) Gets the user data
c) Returns the user data
d) None of the mentioned
Answer
Answer: a [Reason:] The method getUserData(key) returns the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key.
8. How to test if two nodes are equal?
a) isEqualNode()
b) equal()
c) ==
d) none of the mentioned
Answer
Answer: a [Reason:] The method isEqualNode() is used to test if two nodes are equal.
9. How to associate an object to a key on a node?
a) getUserData()
b) cloneNode()
c) setUserData(key,data,handler)
d) none of the mentioned
Answer
Answer: c [Reason:] The method setUserData(key,data,handler) is used to associate an object to a key on a node.
10. Which method is used to compare the placement of two nodes in the DOM hierarchy (document)?
a) compareDocumentPosition()
b) cloneNode()
c) getUserData()
d) getFeature()
Answer
Answer: a [Reason:] The compareDocumentPosition() method is used to compare the placement of two nodes in the DOM hierarchy (document).
Java MCQ Set 5
1. What is the function of the XML parser?
a) Converts XML document to XML DOM object
b) Converts XML DOM object to XML document
c) Converts XML DOM object to a comment
d) None of the mentioned
Answer
Answer: a [Reason:] An XML parser converts an XML document into an XML DOM object – which can then be manipulated with JavaScript.
2. What is the purpose of the method ActiveXObject()?
a) Used to call automation object
b) Used to reference automation object
c) Used to instantiate automation object
d) All of the mentioned
Answer
Answer: c [Reason:] The ActiveXObject() object is used only to instantiate Automation objects, and has no members.
3. What is the purpose of the url json?
a) Belongs to JSON object
b) Reference JSON formatted data
c) Belongs to JSON
d) None of the mentioned
Answer
Answer: b [Reason:] The URL JSON is assumed to reference a file of JSON-formatted data. The value passed to the callback is the object obtained by parsing the URL contents with jQuery.parseJSON(). jQuery.getJSON() uses this type. If the type is “json” and the URL or data string contains “=?”, the type is converted to “jsonp”.
4. What is the parameter of the method Date.parse()?
a) date
b) string
c) datestring
d) string
Answer
Answer: c [Reason:] The parse method is defined as Date.parse(datestring).
5. Which is the function in JavaScript that will print the current page in JavaScript?
a) print()
b) printcurrent()
c) print(now)
d) print(this)
Answer
Answer: a [Reason:] The window.print() can be used to print the current page in JavaScript.
6. To which of the following object does the print() method belong to?
a) window
b) document
c) hash
d) none of the mentioned
Answer
Answer: a [Reason:] The method print() belongs to the window object.
7. What will happen if the radix parameter of the parseInt() function is omitted?
a) Runs in assumption
b) Throws exception
c) Aborts
d) Taken as 0
Answer
Answer: a [Reason:] If the radix parameter is omitted, JavaScript assumes the following:
- If the string begins with “0x”, the radix is 16 (hexadecimal)
- If the string begins with “0”, the radix is 8 (octal). This feature is deprecated
- If the string begins with any other value, the radix is 10 (decimal)
8. What will be the radix value if the string begins with 0x?
a) 13
b) 14
c) 15
d) 16
Answer
Answer: d [Reason:] If the string begins with 0x, then the radix value will be 16.
9. What is the function of the parseInt() method?
a) Parses a datatype and stores in an integer
b) Parses a string and returns an integer
c) Parses an integer and returns a string
d) None of the mentioned
Answer
Answer: b [Reason:] The function parseInt() method parses a string and returns an integer.
10. What does it indicate when the radix value is 16?
a) String begins with 0x
b) String begins with 0
c) String begins with 0P
d) String begins with FF
Answer
Answer: a [Reason:] If the string begins with “0x”, the radix is 16 (hexadecimal).