JavaScript Language | 10 Minute‐Test 7


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.

JavaScript Code can be called by using

A.
RMI
B.
Triggering Event
C.
Preprocessor
D.
Function/Method

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None

2.

The escape sequence ‘\f’ stands for

A.
Floating numbers
B.
Representation of functions that returns a value
C.
\f is not present in JavaScript
D.
Form feed

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

\f is the JavaScript escape sequence that stands for Form feed (\u000C).

3.

Which of the operator is used to test if a particular property exists or not?

A.
in
B.
exist
C.
within
D.
exists

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The operator “in” tests whether a particular property exists.

4.

The “var” and “function” are

A.
Keywords
B.
Declaration statements
C.
Datatypes
D.
Prototypes

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The var and function are declaration statements—they declare or define variables and functions. These statements define identifiers (variable and function names) that can be used elsewhere in your program and assign values to those identifiers.

5.

What will be the step of the interpreter in a jump statement when an exception is thrown?

A.
The interpreter stops its work
B.
The interpreter throws another exception
C.
The interpreter jumps to the nearest enclosing exception handler
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

When an exception is thrown in a jump statement, the interpreter jumps to the nearest enclosing exception handler, which may be in the same function or up the call stack in an invoking function.

6.

Consider the following code snippet

function f() {};
The above prototype represents a

A.
Function f
B.
A custom constructor
C.
Prototype of a function
D.
Not valid

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The above code snippet defines a custom constructor.

7.

Consider the following code snippet :

 var a = [];

 a.unshift(1);

 a.unshift(22);

 a.shift();

 a.unshift(3,[4,5]);

 a.shift();

 a.shift();

 a.shift();


The final output for the shift() is

A.
1
B.
[4,5]
C.
[3,4,5]
D.
Exception is thrown

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The unshift() and shift() methods behave much like push() and pop(), except that they insert and remove elements from the beginning of an array rather than from the end. unshift() adds an element or elements to the beginning of the array, shifts the existing array elements up to higher indexes to make room, and returns the new length of the array. shift() removes and returns the first element of the array, shifting all subsequent elements down one place to occupy the newly vacant space at the start of the array.

8.

Consider the following code snippet

function hypotenuse(a, b)

 {

       function square(x)

       {

            return x*x;

       }

       return Math.sqrt(square(a) + square(b));

}


What does the above code result?

A.
Square root of sum of square of a and b
B.
Square root of square of sum of a and b
C.
Sum of a and b square
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The above code snippet contains nested function in which the function hypotenuse(a,b) has another function inside its scope, function square(x). The interesting thing about nested functions is their variable scoping rules. They can acceess the parameters and variables of the function (or functions) they are nested within.

9.

For the below mentioned code snippet:

var o = new Object();
The equivalent statement is:

A.
var o = Object();
B.
var o;
C.
var o= new Object;
D.
Object o=new Object();

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

You can always omit a pair of empty parentheses in a constructor invocation.

10.

What is the fundamental rule of lexical scoping?

A.
Functions are declared in the scope
B.
Functions are executed using scope chain
C.
Both a and b
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The fundamental rule of lexical scoping is that the JavaScript functions are executed using the scope chain that was in effect when they were defined.


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