JavaScript Language | 10 Minute‐Test 15


Instruction

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

1.

The property of JSON() method is:

A.
it can be invoked manually as object.JSON()
B.
it will be automatically invoked by the compiler
C.
it is invoked automatically by the JSON.stringify() method
D.
it cannot be invoked in any form

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The JSON format is intended for serialization of data structures and can handle JavaScript primitive values, arrays, and plain objects. It does not know about classes, and when serializing an object, it ignores the object’s prototype and constructor. If you call JSON.stringify() on a Range or Complex object, for example, it returns a string like {“from”:1, “to”:3} or {“r”:1, “i”:-1}.

2.

The different variant of Date() constructor to create date object is/are
i. new Date(date)
ii. new Date(milliseconds)
iii. new Date(date string)
iv. new Date(year, month, date[, hour, minute, second, millisecond])

A.
i, ii and iii only
B.
ii, iii and iv only
C.
i, ii and iv only
D.
All i, ii, iii and iv

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The Date() consturctore appears in three different ways as mentioned above.

3.

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.
Both a and b
D.
None of the mentioned

Your Answer: Option (Not Answered)

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

4.

What does the subexpression /java(script)?/ result in ?

A.
It matches “java” followed by the optional “script”
B.
It matches “java” followed by any number of “script”
C.
It matches “java” followed by a minimum of one “script”
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The subexpression /java(script)?/ matches “java” followed by the optional “script”.

5.

Why is the this keyword forbidden in JavaScript?

A.
Highly memory consuming
B.
Functions should access the global objects
C.
Functions should not access the global objects
D.
Very inefficient to use

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The this keyword is forbidden or restricted because functions (in non-strict mode) can access the global object through this. Preventing access to the global object is one of the key purposes of any sandboxing system.

6.

Consider the following code snippet

let x=x+1;
console.log(x);
What will be the result for the above code snippet?

A.
0
B.
Null
C.
ReferenceError
D.
NaN

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Since x is a let variable and since x is undefined, so x+1 is NaN. Thus, the above code snippet prints NaN.

7.

Which method to use while working with XML fragments, instead of XML()?

A.
XMLInterface()
B.
XMLClass()
C.
XMLList()
D.
XMLArray()

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

When working with XML fragments, use XMLList() instead of XML():

pt.element += new XMLList('<element id="6"><name>Carbon</name></element>'+'<element id="7"><name>Nitrogen</name></element>');

8.

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

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

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

9.

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Because packages and classes are represented as JavaScript objects, you can assign themto

importClass(java.util.HashMap); // Same as : var HashMap = java.util.HashMap

variables to give them shorter names. But you can also more formally import them, if you want to:

10.

Among the below given functions, Node supports which of the following client-side timer functions?

A.
getInterval()
B.
Interval()
C.
clearTime()
D.
clearTimeout()
Submit your test now to view the Results and Statistics with answer explanation.