Question 1:
The word “document” mainly refers to
A.
Dynamic Information
B.
Static Information
C.
Both Dynamic and Static Information
D.
None of the mentioned
Answer: _________
Question 2:
Which object is the main entry point to all client-side JavaScript features and APIs?
A.
Standard
B.
Location
C.
Window
D.
Position
Answer: _________
Question 3:
Which identifier is used to represent a web browser window or frame?
A.
frames
B.
window
C.
location
D.
frame
Answer: _________
Question 4:
Which property in the Window object is used to refer to a Location object?
A.
position
B.
area
C.
window
D.
location
Answer: _________
Question 5:
Which Window object method is used to display message in a dialog box?
A.
alert()
B.
prompt()
C.
message()
D.
none of the mentioned
Answer: _________
Question 6:
The setTimeout() method is used to
A.
Make the event sleep
B.
Register a function to be invoked after a certain time
C.
Invoke an event after a certain time
D.
Time for iteration
Answer: _________
Question 7:
Which of the following is a global object?
A.
Register
B.
Location
C.
Window
D.
Position
Answer: _________
Question 8:
When will the window property come into play?
A.
Representation convenience
B.
Use as an extension of other objects
C.
Use objects in the Window object
D.
Refer to window object itself
Answer: _________
Question 9:
Which is the property that represents the content displayed in the window?
A.
document
B.
content
C.
window
D.
frame
Answer: _________
Question 10:
How to pick a document element based on the value of its id attribute?
A.
getElementsbyId()
B.
getElementbyId()
C.
both getElementsbyId() and getElementbyId()
D.
none of the mentioned
Answer: _________
Question 11:
What is the property to access the first child of a node?
A.
timestamp.Child1
B.
timestamp.Child(1)
C.
timestamp.Child(0)
D.
timestamp.firstChild
Answer: _________
Question 12:
What are the properties supporting CSS styles for a document element?
A.
style and font
B.
style and className
C.
size and style
D.
className and font
Answer: _________
Question 13:
The style property belongs to while of the following object?
A.
Element
B.
Window
C.
Location
D.
None of the mentioned
Answer: _________
Question 14:
What is the purpose of the event handlers in the JavaScript?
A.
Adds innerHTML page to the code
B.
Performs handling of exceptions and occurences
C.
Allows JavaScript code to alter the behaviour of windows
D.
None of the mentioned
Answer: _________
Question 15:
Which handler is triggered when the content of the document in the window is stable and ready for manipulation?
A.
onload
B.
manipulate
C.
create
D.
none of the mentioned
Answer: _________
Question 16:
When a program contains extensive use of event handlers, which of the following is necessary?
A.
Modular functions
B.
Nested functions
C.
Split up programs
D.
All of the mentioned
Answer: _________
Question 17:
Which of the following is not an object?
A.
Element
B.
Location
C.
Position
D.
Window
Answer: _________
Question 18:
Rhino is originated by
A.
Microsoft
B.
Mozilla
C.
Apple
D.
None of the mentioned
Answer: _________
Question 19:
Which Rhino command quits Rhino environment?
A.
terminate()
B.
exit()
C.
quit()
D.
close()
Answer: _________
Question 20:
Which is a useful way to try out small and simple Rhino programs and one-liners?
A.
Starting an interative shell
B.
Starting a one to one shell
C.
Creating a thread to do simple programs
D.
None of the mentioned
Answer: _________
Question 21:
What does Rhino do when the getter and setter methods exist?
A.
It becomes JavaScript properties
B.
Java classes are used to avoid them
C.
Java classes & JavaScript properties
D.
None of the mentioned
Answer: _________
Question 22:
The JavaScript classes can be instantiated using _____ operator?
A.
create
B.
new
C.
instantiate
D.
create.new
Answer: _________
Question 23:
The new Java arrays can be created into a JavaScript programs using which of the following classes?
A.
java.Array
B.
java.lang.*
C.
java.lang.Array
D.
java.lang.reflect.Array
Answer: _________
Question 24:
What are the events generated by the Node objects called?
A.
generators
B.
emitters
C.
dispatchers
D.
highevents
Answer: _________
Question 25:
What is the function used to deregister event handler ‘f’?
A.
deleteAllListeners(name)
B.
deleteListener(name,f)
C.
removerListener(name,f)
D.
removeAllListeners(name)
Answer: _________
Question 26:
What is the function used to remove all handlers for name events?
A.
deleteAllListeners(name)
B.
deleteListener(name,f)
C.
removerListener(name,f)
D.
removeAllListeners(name)
Answer: _________
Question 27:
Which function is a synonym for on()?
A.
addListener()
B.
listeners()
C.
once()
D.
add()
Answer: _________
Question 28:
Which of the following is an event emitter?
A.
once
B.
process
C.
listeners
D.
on
Answer: _________
Question 29:
Which among the following POSIX signals generate events?
A.
SIGDOWN
B.
SIGFLOAT
C.
SIGINT
D.
SIGSHORT
Answer: _________
Question 30:
What will be the return value of the write() method when the Node cannot write the data immediately and has to buffer it internally?
A.
0
B.
1
C.
True
D.
False
Answer: _________
Question 31:
Which is a fast C++ based JavaScript interpreter?
A.
Node
B.
Sockets
C.
Processors
D.
Closures
Answer: _________
Question 32:
Why does the Node rely on event handlers?
A.
APIs are synchronous
B.
APIs are asynchronous
C.
APIs are reusable
D.
None of the mentioned
Answer: _________
Question 33:
What is the command to run the node programs?
A.
node(program.js)
B.
program.js
C.
node program.js
D.
node.program.js
Answer: _________
Question 34:
What is the alternative command used in Node for load()?
A.
store()
B.
module()
C.
log()
D.
require()
Answer: _________
Question 35:
Among the below given functions, Node supports which of the following client-side timer functions?
A.
getInterval()
B.
Interval()
C.
clearTime()
D.
clearTimeout()
Answer: _________
Question 36:
The necessary globals of a node are defined under which namespace?
A.
variables
B.
system
C.
process
D.
using
Answer: _________
Question 37:
Why does Node not block while waiting for operations to complete?
A.
Static
B.
Asynchronous
C.
Synchronous
D.
None of the mentioned
Answer: _________
Question 38:
Which is the method used for registering handlers?
A.
on()
B.
register()
C.
add()
D.
include()
Answer: _________
Question 39:
Which of the following is a way of embedding Client-side JavaScript code within HTML documents?
A.
From javascript:encoding
B.
External file specified by the src attribute of a “script” tag
C.
All of the mentioned
D.
None of the mentioned
Answer: _________
Question 40:
When does JavaScript code appear inline within an HTML file?
A.
Between the “script” tag
B.
Outside the “script” tag
C.
Between or Outside the “script” tag
D.
None of the mentioned
Answer: _________
Question 41:
Which character in JavaScript code will be interpreted as XML markup?
A.
!
B.
>
C.
&
D.
.
Answer: _________
Question 42:
Which is the root element in a HTML document?
A.
HTML
B.
HEAD
C.
SCRIPT
D.
BODY
Answer: _________
Question 43:
One of the main advantage of using src attribute is
A.
It becomes self-cached
B.
It makes the HTML file modular
C.
It restricts manipulation in the HTML file
D.
It simplifies the HTML files
Answer: _________
Question 44:
What will be done if more than one page requires a file of JavaScript code?
A.
Downloads that many times
B.
Retrives from the browser cache
C.
Must be re executed
D.
None of the mentioned
Answer: _________
Question 45:
What is the default value of the type attribute?
A.
text/css
B.
text/javascript
C.
text
D.
xml
Answer: _________
Question 46:
The language is commonly used to
A.
Specify the user’s language
B.
Specify the language going to be scripted
C.
No longer in use
D.
Specify the programmer’s favorable language
Answer: _________
Question 47:
The main purpose of JavaScript in web browser is to
A.
Creating animations and other visual effects
B.
User Interface
C.
Visual effects
D.
None of the mentioned
Answer: _________
Question 48:
A JavaScript program can traverse and manipulate document content through
A.
Element Object
B.
Document Object
C.
Both Element and Document Object
D.
None of the mentioned
Answer: _________
Question 49:
The behaviour of the document elements can be defined by
A.
Using document object
B.
Registering appropriate event handlers
C.
Using element object
D.
All of the mentioned
Answer: _________
Question 50:
The service(s) that enables networking through scripted HTTP requests is
A.
XMLHttpResponse
B.
XMLRequest
C.
XMLHttpRequest
D.
All of the mentioned
Answer: _________
Question 51:
The HTML5 specification includes
A.
Data storage
B.
Graphics APIs
C.
Other APIs for web apps
D.
All of the mentioned
Answer: _________
Question 52:
Which of the following are not advanced services?
A.
Data storage
B.
Networking
C.
XMLHttpRequest object
D.
None of the mentioned
Answer: _________
Question 53:
JavaScript code between a pair of “script” tags are called
A.
Non-inline
B.
External
C.
Referenced
D.
Inline
Answer: _________
Question 54:
Client-side JavaScript code is embedded within HTML documents in
A.
A URL that uses the special javascript:encoding
B.
A URL that uses the special javascript:stack
C.
A URL that uses the special javascript:protocol
D.
A URL that uses the special javascript:code
Answer: _________
Question 55:
What is the programming philosophy that argues that content and behaviour should as much as possible be kept separate?
A.
Unobtrusive JavaScript
B.
Obtrusive JavaScript
C.
Inherited JavaScript
D.
Modular JavaScript
Answer: _________
Question 56:
Which of the following communicates with server-side CGI scripts through HTML form submissions and can be written without the use of JavaScript?
A.
Static Web Pages
B.
Interactive Web Pages
C.
Conditional Web Pages
D.
None of the mentioned
Answer: _________
Question 57:
The libraries that build a new higher-level API for client-side programming is
A.
Library
B.
Framework
C.
APIs
D.
All of the mentioned
Answer: _________
Question 58:
Which of the following is not a framework?
A.
jQuery
B.
.NET
C.
JavaScript
D.
None of the mentioned
Answer: _________
Question 59:
Which of the following frameworks focuses on DOM and Ajax utilities?
A.
jQuery
B.
Prototype
C.
Dojo
D.
Both jQueryand Prototype
Answer: _________
Question 60:
What is the purpose of Dojo framework?
A.
Focuses on DOM and Ajax utilities
B.
Advertises incredible depth
C.
Ajax utilities
D.
None of the mentioned
Answer: _________
Question 61:
Which is the in-house library of Yahoo!?
A.
Dojo
B.
YUI
C.
Prototype
D.
Closure
Answer: _________
Question 62:
What does Dojo and YUI have in common?
A.
Facilitates DOM utilities and UI Widgets
B.
Doesnot facilitates DOM utilities and UI Widgets
C.
Client-side library
D.
None of the mentioned
Answer: _________
Question 63:
What are the two incompatible versions of YUI?
A.
YUI1 and YUI2
B.
YUI2 and YUI4
C.
YUI1 and YUI3
D.
YUI2 and YUI3
Answer: _________
Question 64:
Which of the following framework was used by Google for Gmail?
A.
Dojo
B.
GWT
C.
Closure
D.
YUI
Answer: _________
Question 65:
Which of the following is a web application API framework?
A.
Dojo
B.
YUI
C.
GWT
D.
All of the mentioned
Answer: _________
Question 66:
Which is more widely used than GWT in Google?
A.
Closure
B.
Dojo
C.
Procedure
D.
jQuery
Answer: _________
Question 67:
What is the code for getting the current time?
A.
now = new Date()
B.
var now = new Date()
C.
var now = Date()
D.
var now = new Date(current)
Answer: _________
Question 68:
What is the code to start displaying the time when document loads?
A.
onload = displayTime
B.
window. = displayTime
C.
window.onload = displayTime
D.
window.onload = start
Answer: _________
Question 69:
What is the command used for debugging output in Node?
A.
print()
B.
console.log(…)
C.
debug(…)
D.
execute(…)
Answer: _________
Question 70:
What is the code to print hello one second from now?
A.
setTimeout(function() { console.log("Hello World")
}, 1000)
B.
setTimeout(function() { 1000, console.log("Hello World")
})
C.
setTimeout(function(1000) { console.log("Hello World")
})
D.
setTimeout(function() { console.log("Hello World")
})
Answer: _________
Question 71:
Which of the following are global functions that are not part of core JavaScript?
A.
spawn(f)
B.
trim()
C.
exult()
D.
none of the mentioned
Answer: _________
Question 72:
Which of the following reads the textual contents of a URL and returns as a string?
A.
spawn(f)
B.
load(filename,…)
C.
readFile(file)
D.
readUrl(url)
Answer: _________
Question 73:
Which is a more formal way of importing packages and classes as JavaScript objects?
A.
import(java.util.*)
B.
importClass(java.util.*)
C.
import.Class(java.util.*)
D.
Class.import(java.util.*)
Answer: _________
Question 74:
Consider the following code snippet var f = new java . io . File ( "/tmp/test" )
var out = new java . io . FileWriter ( f )
out instanceof java.io.Reader What will be the output for the above code snippet?
A.
Error
B.
True
C.
Exception
D.
False
Answer: _________
Question 75:
When do uncaught exceptions generate events?
A.
When handlers are registered
B.
When handlers are deregistered
C.
When handler functions are called
D.
When handlers do not have a matching catch clause
Answer: _________
Question 76:
What is the method used to pause “data” events?
A.
s.pause()
B.
s.stop()
C.
s.halt()
D.
s.wait()
Answer: _________
Question 77:
When the “end” event fires on EOF when no more data will arrive, which function is called?
A.
s.on("data",f)
B.
s.on("end",f)
C.
s.on("error",f)
D.
s.on("default",f)
Answer: _________
Question 78:
What is the code snippet to find all container elements with class “reveal”?
A.
var elements = document.getElementsByClassName("reveal")
B.
var elements = document.getElementByClassName("reveal")
C.
var elements = document.getElementByName("reveal")
D.
var elements = document.getElementsClassName("reveal")
Answer: _________
Question 79:
What is the code snippet to update the content of the timestamp element when the user clicks on it?
A.
timestamp.onLoad = function() { this.innerHTML = new Date().toString()
}
B.
timestamp.onclick = function() { this.innerHTML = new Date().toString()
}
C.
timestamp.onclick = function() { innerHTML = new Date().toString()
}
D.
None of the above
Answer: _________
Question 80:
What is the code snippet to change the class and let the stylesheet specify the details?
A.
timestamp.className = "highlight"
B.
timestamp.className = "change"
C.
timestamp.className = "specify"
D.
timestamp.className = "move"
Answer: _________
Answer Key
1:
B
Solution: Some pages present static information and can be called documents.
2:
C
Solution: The Window object is the main entry point to all client-side JavaScript features and APIs. It represents a web browser window or frame, and you can refer to it with the identifier window.
3:
B
Solution: The Window object is the main entry point to all client-side JavaScript features and APIs. It represents a web browser window or frame, and you can refer to it with the
identifier window.
4:
D
Solution: The Window object defines properties like location, which refers to a Location object that specifies the URL currently displayed in the window and allows a script to load a new URL into the window.
5:
A
Solution: The Window object also defines methods like alert() , which displays a message in a dialog box.
6:
B
Solution: The setTimeout() , which registers a function to be invoked after a specified amount of time.
7:
C
Solution: In client-side JavaScript, the Window object is also the global object. This means that the Window object is at the top of the scope chain and that its properties and methods are effectively global variables and global functions.
8:
D
Solution: The Window object has a property named window that always refers to itself. You can use this property if you need to refer to the window object itself, but it is not usually necessary to use window if you just want to refer to access properties of the global window object.
9:
A
Solution: One of the most important properties of the Window object is document: it refers to a Document object that represents the content displayed in the window.
10:
B
Solution: The Document object has important methods such as getElementById(), which returns a single document element (representing an open/close pair of HTML tags and all of the content between them) based on the value of its id attribute.
11:
D
Solution: The first child of a node can be accessed using the firstChild property.
12:
B
Solution: Each Element object has style and className properties that allow scripts to specify CSS styles for a document element or to alter the CSS class names that apply to the element.
13:
A
Solution: Each Element object has style and className properties that allow scripts to specify CSS styles for a document element or to alter the CSS class names that apply to the element.
14:
C
Solution: Event handlers allow JavaScript code to alter the behavior of windows, of documents, and of the elements that make up those documents.
15:
A
Solution: One of the most important event handlers is the onload handler of the Window object. It is triggered when the content of the document displayed in the window is stable and ready to be manipulated. JavaScript code is commonly wrapped within an onload event handler.
16:
B
Solution: Nested functions are common in client-side JavaScript, because of its extensive use of event handlers.
17:
C
Solution: There is no object called Position.
18:
B
Solution: Rhino is free software from Mozilla.
19:
C
Solution: The quit() command makes Rhino exit.
20:
A
21:
A
Solution: Rhino allows JavaScript code to query and set the static fields of Java classes and the instance fields of Java objects. Java classes often avoid defining public fields in favor of getter and setter methods. When getter and setter methods exist, Rhino exposes them as JavaScript properties.
22:
B
Solution: Just like the JavaScript classes use new operator to instantiate, so does the Java classes.
23:
D
Solution: There is no natural JavaScript syntax that Rhino can extend to allow JavaScript programs to create new Java arrays, so you have to do that using the java.lang.reflect.Array class.
24:
B
Solution: Node objects that generate events (known as event emitters) define an on() method for registering handlers.
25:
C
26:
D
Solution: The removeAllListeners(name) is used to remove all handlers from name events represented as : emitter.removeAllListeners(name)
27:
A
Solution: The on() method is used for registering handlers. addListener() is a synonym for on().
28:
B
Solution: The process object is an event emitter. The Node defines other important globals under the process namespaces that contain properties of that object like version, argv, env, pid,getuid(), cwd(), chdir() and exit().
29:
C
Solution: The SIGINT is a POSIX signal that generates event.
30:
D
Solution: The write() method never blocks. If Node cannot write the data immediately and has to buffer it internally, the write() method returns false.
31:
A
Solution: Node is a fast C++-based JavaScript interpreter with bindings to the low-level Unix APIs for working with processes, files, network sockets, etc., and also to HTTP client and server APIs.
32:
B
Solution: Because the APIs are asynchronous, Node relies on event handlers, which are often implemented using nested functions and closures.
33:
C
Solution: The node programs can be run with the command: node program.js
34:
D
Solution: Use require() instead of load(). It loads and executes (only once) the named module, returning an object that contains its exported symbols.
35:
D
Solution: Node supports the client-side timer functions set setTimeout() , setInterval() , clearTimeout() , and clearInterval() .
36:
C
Solution: Node defines other important globals under the process namespace.
37:
B
Solution: Because Node’s functions and methods are asynchronous, they do not block while waiting for operations to complete.
38:
A
Solution: Node objects that generate events (known as event emitters) define an on() method for registering handlers.
39:
B
Solution: The Client-side JavaScript code is embedded within HTML documents in four ways : 1. Inline, between a pair of “script” tags 2. From an external file specified by the src attribute of a “script” tag 3. In an HTML event handler attribute, such as onclick or onmouseover 4. In a URL that uses the special javascript: protocol.
40:
A
Solution: JavaScript code can appear inline within an HTML file between the “script” tags.
41:
C
Solution: If your JavaScript code contains the < or & characters, these characters are interpreted as XML markup.
42:
A
Solution: The “html” tag is the root element of any HTML document regardless of it containing a JavaScript code or not.
43:
D
Solution: The main advantage of using the src attribute is that it simplifies your HTML files by allowing you to remove large blocks of JavaScript code from them—that is, it helps keep content and behavior separate.
44:
B
Solution: If a file of JavaScript code is shared by more than one page, it only needs to be downloaded once, by the first page that uses it—subsequent pages can retrieve it from the browser cache.
45:
B
Solution: The default value of the type attribute is “text/javascript”. You can specify this type explicitly if you want, but it is never necessary.
46:
C
Solution: The language attribute is deprecated and should no longer be used.
47:
A
Solution: JavaScript can help to facilitate that experience, for example by: 1. Creating animations and other visual effects to subtly guide a user and help with page navigation 2. Sorting the columns of a table to make it easier for a user to find what she needs 3. Hiding certain content and revealing details progressively as the user “drills down” into that content
48:
C
Solution: A JavaScript program can traverse and manipulate document content through the Document object and the Element objects it contains. It can alter the presentation of that content by scripting CSS styles and classes.
49:
B
Solution: The JavaScript program can define the behavior of document elements by registering appropriate event handlers.
50:
C
Solution: The best known advanced services is the XMLHttpRequest object, which enables networking through scripted HTTP requests.
51:
D
Solution: The HTML5 specification (which, at the time of this writing, is still in draft form) and related specifications are defining a number of other important APIs for web apps.
These include the data storage and graphics APIs.
52:
D
Solution: All the above mentioned are advanced services.
53:
D
Solution: Inline code are those that are writeen between a pair of “script” tags.
54:
C
Solution: The Client-side JavaScript code is embedded within HTML documents in four ways : 1. Inline, between a pair of “script” tags 2. From an external file specified by the src attribute of a “script” tag 3. In an HTML event handler attribute, such as onclick or onmouseover 4. In a URL that uses the special javascript: protocol.
55:
A
Solution: A programming philosophy known as unobtrusive JavaScript argues that content (HTML) and behavior (JavaScript code) should as much as possible be kept separate. According to this programming philosophy, JavaScript is best embedded in HTML documents using “script” elements with src attributes.
56:
B
Solution: nteractive web pages that communicate with server-side CGI scripts through HTML form submissions were the original “web application” and can be written without the use of JavaScript.
57:
B
Solution: Many web developers find it useful to build their web applications on top of a clientside framework library. These libraries are “frameworks” in the sense that they build a new higher-level API for client-side programming on top of the standard and proprietary APIs offered by web browsers: once you adopt a framework, your code needs to be written to use the APIs defined by that framework.
58:
C
Solution: One of the most popular frameworks is jQuery. Here, JavaScript is a scripting language and not a framework.
59:
D
Solution: The Prototype library focuses on DOM and Ajax utilities like jQuery does, and adds quite a few core-language utilities as well.
60:
B
Solution: Dojo is a large framework that advertises its “incredible depth.” It includes an extensive set of UI widgets, a package system, a data abstraction layer, and more.
61:
B
Solution: YUI is the in-house library of Yahoo!, and it is used on their home page.
62:
A
Solution: Like Dojo, it is a large, all-encompassing library with language utilities, DOM utilities, UI widgets, and so on. There are actually two incompatible versions of YUI, known as YUI 2 and YUI 3.
63:
A
Solution: Like Dojo, it is a large, all-encompassing library with language utilities, DOM utilities, UI widgets, and so on. There are actually two incompatible versions of YUI, known as YUI 2 and YUI 3.
64:
D
Solution: The Closure library is the client-side library that Google uses for Gmail, Google Docs, and other web applications. This library is intended to be used with the Closure compiler, which strips out unused library functions.
65:
C
Solution: GWT, the Google Web Toolkit , is a completely different kind of client-side framework. It defines a web application API in Java and provides a compiler to translate your Java programs into compatible clientside JavaScript.
66:
A
Solution: GWT, the Google Web Toolkit , is a completely different kind of client-side framework. It defines a web application API in Java and provides a compiler to translate your Java programs into compatible client-side JavaScript. GWT is used in some of Google’s products, but it is not as widelyused as their Closure library.
67:
B
Solution: The above code determines the current time and stores it in the variable “now”.
68:
C
Solution: The above code starts displaying the time when the document loads.
69:
B
Solution: Node defines console.log() for debugging output like browsers do.
70:
A
Solution: The above code snippet says hello one second from now.
71:
A
Solution: The spawn(f) runs f() or loads and executes file f in a new thread.
72:
D
Solution: Rhino defines a handful of important global functions that are not part of core JavaScript in which readUrl(url) reads the textual contents of a URL and return as a string.
73:
B
Solution: Because packages and classes are represented as JavaScript objects, you can assign themto variables to give them shorter names. But you can also more formally import them, if you want to: importClass ( java . util . HashMap )
// Same as : var HashMap = java.util.HashMap
74:
D
Solution: The output for the above code snippet is false as it is a writer and not a Reader.
75:
A
Solution: Uncaught exceptions generate events, if any handlers are registered. Otherwise, the exception just makes Node print an error and exit. process . on (" uncaughtException " , function ( e ) { console . log ( Exception, e )
})
76:
A
Solution: The above code snippet is used to pause data events, for throttling uploads, e.g.
77:
B
Solution: The above code snippet gets “end” event fired on EOF when no more data will arrive.
78:
A
Solution: The above code snippet finds all container elements with class “reveal”.
79:
B
Solution: The above code snippet updates the content of the timestamp element when the user clicks on it.
80:
A
Solution: The above code snippet changes the class and lets the stylesheet specify the details.