JavaScript Language | 30 Minute Test 9


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.

The script tag must be placed in

A.
head
B.
head and body
C.
title and head
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

If the script tag is placed after the body tag, then, it will not be evaluated at all. Also, it is always recommended and effective to use the script snippet in the tag.

2.

A hexadecimal literal begins with

A.
00
B.
0x
C.
0X
D.
Both b and c

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Generally, X or x denotes hexadecimal values. So, any integer literal that begins with 0X or 0x denotes a hexadecimal number.

3.

The property of a primary expression is

A.
stand-alone expressions
B.
basic expressions containing all necessary functions
C.
contains variable references alone
D.
complex expressions

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The simplest expressions, known as primary expressions, are those that stand alone — they do not include any simpler expressions. Primary expressions in JavaScript are constant or literal values, certain laguage keywords, and variable references.

4.

A conditional expression is also called a

A.
Alternate to if-else
B.
Immediate if
C.
If-then-else statement
D.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

A conditional expression can evaluate to either True or False based on the wvaluation of the condition.

5.

Consider the following code snippet

function tail(o)

{

    for (; o.next; o = o.next) ;

    return o;

}


Will the above code snippet work? If not, what will be the error?

A.
No, this will throw an exception as only numerics can be used in a for loop
B.
No, this will not iterate
C.
Yes, this will work
D.
No, this will result in a runtime error with the message “Cannot use Linked List”

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The above code uses a for loop to traverse a linked list data structure and return the last object in the list. This will perfectly work.

6.

Consider the following code snippet :

var book = {

"main title": "JavaScript",

'sub-title': "The Definitive Guide",

"for": "all audiences",

author: {

firstname: "David",

surname: "Flanagan"

}

};


In the above snippet, firstname and surname are

A.
properties
B.
property values
C.
property names
D.
objects

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

firstname and surname are the property names. The value of that particular property is itself an object. That is why these property names are unquoted.

7.

The pop() method of the array does which of the following task ?

A.
decrements the total length by 1
B.
increments the total length by 1
C.
prints the first element but no effect on the length
D.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Arrays have a pop() method (it works with push()) that reduces the length of an array by 1 but also returns the value of the deleted element.

8.

When does the function name become optional in JavaScript?

A.
When the function is defined as a looping statement
B.
When the function is defined as expressions
C.
When the function is predefined
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The function name is optional for functions defined as expressions. A function declaration statement actually declares a variable and assigns a function object to it.

9.

Consider the following code snippet :

var tensquared = (function(x) {return x*x;}(10));
Will the above code work ?

A.
Yes, perfectly
B.
Error
C.
Exception will be thrown
D.
Memory leak

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Function name is optional for functions defined as expressions. Function expressions are sometimes defined and immediately invoked.

10.

What is a closure?

A.
Function objects
B.
Scope where function’s variables are resolved
C.
Both a and b
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

A combination of a function object and a scope (a set of variable bindings) in which the function’s variables are resolved is called a closure.

11.

Consider the following code snippet :

var o = new F();
o.constructor === F
The output would be :

A.
false
B.
true
C.
1
D.
0

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The result is true: the constructor property specifies the class.

12.

The object whose properties are inherited by all instances of the class, and properties whose values are functions behaving like instance methods of the class, is

A.
Instance object
B.
Constructor object
C.
Destructor object
D.
Prototype object

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The properties of the prototype object are inhertied by all instances of the class, and properties whose values are functions behave like instance methods of the class.

13.

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

Your Answer: Option (Not Answered)

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

14.

The regular expression to match any one character not between the brackets is

A.
[…]
B.
[^]
C.
[^…]
D.
[\D]

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The [^…] character class is used to match or draw any one character not between the brackets.

15.

What is being imposed on each subset to ensure that it conforms to the subset?

A.
A parser to parse the code
B.
A parser that parses and adds to the subset
C.
A static verifier that parses code
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Each subset is coupled with a static verifier that parses code to ensure that it conforms to the subset.

16.

The main difference between the variables declared with var and with let is

A.
var is confined to a particular function but let is not
B.
let is confined to a particular function but var is not
C.
var defines values based on conditions but let does not
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Variables declared with var are defined throughout the enclosing function. Variables declared with let are defined only within the closest enclosing block (and any blocks nested within it, of course).

17.

What will be the reaction when a catch clause has no conditionals ?

A.
Takes it to be 0
B.
Takes it to be 1
C.
Takes it to be true
D.
Takes it to be false

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

If a catch clause has no conditional, it behaves as if it has the conditional if true, and it is always triggered if no clause before it was triggered.

18.

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)

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The removeAllListeners(name) is used to remove all handlers from name events represented as :
emitter.removeAllListeners(name)

19.

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);

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

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.

20.

What is the command to run the node programs?

A.
node(program.js)
B.
program.js
C.
node program.js
D.
node.program.js

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The node programs can be run with the command:
node program.js

21.

Which is the Microsoft’s own proprietary client-side storage?

A.
IE User Data
B.
Offline Web Applications
C.
Cookies
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Microsoft implements its own proprietary client-side storage mechanism, known as “userData,” in IE5 and later. userData enables the storage of medium amounts of string data and can be used as an alternative to Web Storage in versions of IE before IE8.

22.

Which character in JavaScript code will be interpreted as XML markup?

A.
!
B.
>
C.
&
D.
.

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

If your JavaScript code contains the < or & characters, these characters are interpreted as XML markup.

23.

Which identifier is used to represent a web browser window or frame?

A.
frames
B.
window
C.
location
D.
frame

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

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.

24.

The style property belongs to while of the following object?

A.
Element
B.
Window
C.
Location
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

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.

25.

Which of the following frameworks focuses on DOM and Ajax utilities?

A.
jQuery
B.
Prototype
C.
Dojo
D.
Both a and b

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The Prototype library focuses on DOM and Ajax utilities like jQuery does, and adds quite a few core-language utilities as well.

26.

Which is the handler method used to invoke when uncaught JavaScript exceptions occur?

A.
onhalt
B.
onerror
C.
Both a and b
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The onerror handler method can be registered to be invoked when uncaught JavaScript exceptions occur.

27.

Which among the following is not a property of the Location object?

A.
protocol
B.
host
C.
hostee
D.
hostname

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The various properties of the location object are the protocol, host, hostname, port, search, and hash.

28.

The length property belongs to which of the following objects?

A.
Window
B.
Element
C.
History
D.
Document

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The length property of the History object specifies the number of elements in the browsing history list, but for security reasons scripts are not allowed to access the stored URLs.

29.

What is the distinction made by the Client-side JavaScript between windows, tabs, iframes, and frames ?

A.
They are all browsing contexts
B.
They are all browsing informations
C.
They are all Window contexts
D.
They are all Window objects

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Client-side JavaScript makes very little distinction between windows, tabs, iframes, and frames: they are all browsing contexts, and to JavaScript, they are all Window objects.

30.

The node directly above a node is called

A.
sibling
B.
child
C.
parent
D.
ancestors

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The node directly above a node is the parent of that node.

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