JavaScript Language | 30 Minute Test 6


Instruction

  • Total number of questions : 30.
  • Time alloted : 30 minutes.
  • Each question carry 1 mark.
  • No Negative marks
  • DO NOT refresh the page.
  • All the best :-).

1.

Which of the following Attribute is used to include External JS code inside your HTML Document

A.
src
B.
ext
C.
script
D.
link

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

A ”src” attribute could be used to add any external code into the HTML document.

2.

The statement a===b refers to

A.
Both a and b are equal in value, type and reference address
B.
Both a and b are equal in value
C.
Both a and b are equal in value and type
D.
There is no such statement

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

a==b returns a true if a and b refer to the same objec ,so they are equal, else it returns a false.

3.

“An expression that can legally appear on the left side of an assignment expression.” is a well known explanation for variables, properties of objects, and elements of arrays. They are called

A.
Properties
B.
Prototypes
C.
lvalue
D.
Definition

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

lvalue is a historical term that means “an expression that can legally appear on the left side of an assignment expression.” In JavaScript, variables, properties of objects, and elements of arrays are lvalues.

4.

Consider the following statements

var count = 0;

while (count < 10)

{

     console.log(count);

     count++;

}


In the above code snippet, what happens?

A.
The values of count is logged or stored in a particular location or storage.
B.
The value of count from 0 to 9 is displayed in the console.
C.
An error is displayed
D.
An exception is thrown

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

5.

Consider the following code snippet

function f(o)

{

     if (o === undefined) debugger;

}


What could be the task of the statement debugger?

A.
It does nothing but a simple breakpoint
B.
It debugs the error in that statement and restarts the statement’s execution
C.
It is used as a keyword that debugs the entire program at once
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The debugger statement normally does nothing. If, however, a debugger program is available and is running, then an implementation may (but is not required to) perform some kind of debugging action. In practice, this statement acts like a breakpoint: execution of JavaScript code stops and you can use the debugger to print variable’s values.

6.

Identify the process done in the below code snippet

o = {x:1, y:{z:[false,null,""]}};

s = JSON.stringify(o);

p = JSON.parse(s);

A.
Object Encapsulation
B.
Object Serialization
C.
Object Abstraction
D.
Object Encoding

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Object serialization is the process of converting an object’s state to a string from which it can later be restored.

7.

The reduce and reduceRight methods follow a common operation called

A.
filter and fold
B.
inject and fold
C.
finger and fold
D.
fold

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None

8.

Which is an equivalent code to invoke a function m of class o that expects two arguments x and y?

A.
o(x,y);
B.
o.m(x) && o.m(y);
C.
m(x,y);
D.
o.m(x,y);

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The code above is an invocation expression: it includes a function expression o.m and two argument expressions, x and y.

9.

Consider the following code snippet :

var c = counter(),d = counter();

c.count()

d.count()

c.reset()

c.count()

d.count()


The state stored in d is :

A.
1
B.
0
C.
Null
D.
Undefined

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The state stored in d is 1 because d was not reset.

10.

What is the purpose of the dynamic scoping?

A.
Variables can be declared outside the scope
B.
Variables must be declared outside the scope
C.
Variables cannot be declared outside the scope
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Dynamic scoping creates variables that can be called from outside the block of code in which they are defined. A variable declared in this fashion is sometimes called a public variable.

11.

The method that can be used to create new properties and also to modify the attributes of existing properties is

A.
Object.defineProperty()
B.
Object.defineProperties()
C.
Both a and b
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

When used to define new properties, any attributes you omit default to false. Therefore, both Object.defineProperty() and Object.defineProperties() can be used to create and modify the attributes.

12.

You can refresh the webpage in JavaScript by using

A.
window.reload
B.
location.reload
C.
window.refresh
D.
page.refresh

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

One can refresh the webpage in JavaScript by using location.reload.

13.

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

Your Answer: Option (Not Answered)

Correct Answer: Option 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).

14.

What would be the result of the following statement in JavaScript using regular expression methods ?

A.
Returns [“123″”456″”789”]
B.
Returns [“123″,”456″,”789”]
C.
Returns [1,2,3,4,5,6,7,8,9]
D.
Throws an exception

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The split() method can take regular expressions as its arguments. The split() method generally breaks the string on which it is called into an array of substrings, using the argument as a separator.

15.

Which was one of the first security subsets proposed?

A.
FBJS
B.
Caja
C.
dojox.secure
D.
ADSafe

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

ADsafe was one of the first security subsets proposed. It was created by Douglas Crockford (who also defined The Good Parts subset).ADsafe relies on static verification only, and it uses JSLint as its verifier. It forbids access to most global variables and defines an ADSAFE variable that provides access to a secure API, including special-purpose DOM methods. ADsafe is not in wide use, but it was an influential proof-of-concept that influenced other secure subsets.

16.

Which exception does the Iterators throw from their next() method when there are no more values to iterate, that work on finite collections ?

A.
ExitIteration
B.
AbortIteration
C.
Abort
D.
StopIteration

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Iterators that work on finite collections throw StopIteration from their next() method when there are no more values to iterate. StopIteration is a property of the global object in JavaScript 1.7. Its value is an ordinary object (with no properties of its own) that is reserved for this special purpose of terminating iterations. Note, in particular,that StopIteration is not a constructor function like TypeError() or RangeError().

17.

What is the code required to delete all “weight” tags?

A.
delete weight(pt).all;
B.
delete pt.element[all];
C.
delete pt;
D.
delete pt..weight;

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Removing attributes and tags is very easy with the standard delete operator :

delete pt..weight; //delete all <weight> tags

18.

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

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The write() method never blocks. If Node cannot write the data immediately and has to buffer it internally, the write() method returns false.

19.

The JavaScript classes can be instantiated using _____ operator?

A.
create
B.
new
C.
instantiate
D.
create.new

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Just like the JavaScript classes use new operator to instantiate, so does the Java classes.

20.

Which is the method used for registering handlers?

A.
on()
B.
register()
C.
add()
D.
include()

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Node objects that generate events (known as event emitters) define an on() method for registering handlers.

21.

Which is the function used to retrieve a value?

A.
get()
B.
retrieve()
C.
getItem()
D.
retrieveItem()

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

To retrieve a value, pass the name to getItem().

22.

What is the default value of the type attribute?

A.
text/css
B.
text/javascript
C.
text
D.
xml

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The default value of the type attribute is “text/javascript”. You can specify this type explicitly if you want, but it is never necessary.

23.

Which is the property that represents the content displayed in the window?

A.
document
B.
content
C.
window
D.
frame

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

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.

24.

How to pick a document element based on the value of its id attribute?

A.
getElementsbyId()
B.
getElementbyId()
C.
Both a and b
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

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.

25.

Which of the following is a web application API framework?

A.
Dojo
B.
YUI
C.
GWT
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

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.

26.

To which object does the location property belong?

A.
Window
B.
Position
C.
Element
D.
Location

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The location property of the Window object refers to a Location object, which represents the current URL of the document displayed in the window, and which also defines methods for making the window load a new document.

27.

What is the purpose of the assign() method?

A.
Only loading
B.
Loading of window and display
C.
Displays already present window
D.
Unloading of window

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The assign() method of the Location object makes the window load and display the document at the URL you specify.

28.

Which of the below properties can be used for browser sniffing?

A.
platform
B.
appVersion
C.
Both a and b
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The platform and appVersion can be used for browser sniffing.

29.

When will the fourth argument to open() useful?

A.
When the second argument names a retired window
B.
When the first argument names an existing window
C.
When the second argument names an existing window
D.
When the first argument names a retired window

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The fourth argument to open() is useful only when the second argument names an existing window. This fourth argument is a boolean value that indicates whether the URL specified as the first argument should replace the current entry in the window’s browsing history (true) or create a new entry in the window’s browsing history (false). Omitting this argument is the same as passing false.

30.

Which of the following property refers to the root element of the document?

A.
documentElement
B.
Elementdocument
C.
rootdocument
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The documentElement property of the Document class refers to the root element of the document. This is always an HTML element.

Submit your test now to view the Results and Statistics with answer explanation.