JavaScript Language | 30 Minute Test 4


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.

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.

11.

When a class B can extend another class A, we say that

A.
A is the superclass and B is the subclass
B.
B is the superclass and A is the subclass
C.
Both A and B are the superclass
D.
Both A and B are the subclass

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Instances of B inherit all the instance methods of A. The class B can define its own instance methods, some of which may override methods of the same name defined by class A.

12.

How can we make methods available on all objects?

A.
Object.add(methods)
B.
Object.methods(add)
C.
Object.add.methods(…)
D.
Object.prototype

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

It is possible to add methods to Object.prototype, making them available on all objects. This is not recommended, however, because prior to ECMAScript5, there is no way to make these add-on methods nonenumerable, and if you add properties to Object.prototype, those properties will be reported by all for/in loops.

13.

Consider the following code snippet

var sets = com.davidflanagan.collections.sets;
What is the programmer trying to do in the above code snippet?

A.
Importing a single module
B.
Importing a module partially
C.
Importing a namespace
D.
Importing the entire module

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Rather than importing individual classes, a programmer might import the entire module to the global namespace.

14.

What is the most essential purpose of parantheses in regular expressions ?

A.
Define pattern matching techniques
B.
Define subpatterns within the complete pattern
C.
Define portion of strings in the regular expression
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

When a regular expression is successfullyy matched against a target string, it is possible to extract the portions of the target string that matched any particular paranthesized subpattern. The essential purpose of parantheses in regular expressions is to define subpatterns within the complete pattern.

15.

Which are the two functions that are not allowed in any secure subset?

A.
evaluate() and restrict()
B.
eval() and the Function() constructor
C.
debugger() and test()
D.
eval() and debugger()

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

eval() and the Function() constructor are not allowed in any secure subset because they allow the execution of arbitrary strings of code, and these strings cannot be statically analyzed.

16.

Consider the following code snippet

[x,y]=[y,x];
What is the result of the above code snippet?

A.
Throws exception
B.
Swap the value of the two variables
C.
Flashes an error
D.
Creates a new reference object

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The above code snippet swaps the value of the two variables.

17.

Which of the following is the descendant operator?

A.
..
B.
C.
*
D.
@

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The .. operator is the descendant operator; you can use it in place of the normal . member-access operator :

var names = pt..name;

18.

Which among the following POSIX signals generate events?

A.
SIGDOWN
B.
SIGFLOAT
C.
SIGINT
D.
SIGSHORT

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The SIGINT is a POSIX signal that generates event.

19.

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

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The output for the above code snippet is false as it is a writer and not a Reader.

20.

The necessary globals of a node are defined under which namespace?

A.
variables
B.
system
C.
process
D.
using

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Node defines other important globals under the process namespace.

21.

What is the main difference between localStorage and sessionStorage?

A.
Lifetime
B.
Scope
C.
Both a and b
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The difference between localStorage and sessionStorage has to do with lifetime and scope: how long the data is saved for and who the data is accessible to.

22.

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

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

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.

23.

Which of the following is a global object?

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

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

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.

24.

Which of the following is not an object?

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

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

There is no object called Position.

25.

What are the two incompatible versions of YUI?

A.
YUI2 and YUI3
B.
YUI2 and YUI4
C.
YUI1 and YUI3
D.
YUI1 and YUI2

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

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.

26.

Which method receives the return value of setTimeout() to cancel future invocations?

A.
clearTimeout()
B.
clearInterval()
C.
clearSchedule()
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

setTimeout() returns a value that can be passed to clearTimeout() to cancel the execution of the scheduled function.

27.

Which is the method that removes the current document from the browsing history before laoding the new document?

A.
modify()
B.
assign()
C.
replace()
D.
remove()

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The replace() method is similar, but it removes the current document from the browsing history before loading the new document. When a script unconditionally loads a new document, the replace() method is often a better choice than assign().

28.

What is the vendor-neutral synonym for navigator?

A.
staticData
B.
purposeInformation
C.
dataInformation
D.
clientInformation

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

IE supports clientInformation as a vendor-netural synonym for navigator.

29.

Which object serves as the global object at the top of the scope chain?

A.
Hash
B.
Property
C.
Element
D.
Window

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The Window object serves as the global object at the top of the scope chain in client-side JavaScript.

30.

Which is one of way to query a document for an element or elements?

A.
With a specified id attribute
B.
Matching the specified CSS selector
C.
With the specified tag name
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The DOM defines a number of ways to select elements; you can query a document for an element or elements:
1.with a specified id attribute;
2.with a specified name attribute;
3.with the specified tag name;
4.with the specified CSS class or classes; or
5.matching the specified CSS selector

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