JavaScript Language | 10 Minute‐Test 16


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.

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.

2.

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.

3.

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.

4.

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.

5.

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.

6.

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.

7.

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;

8.

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.

9.

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.

10.

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

A.
variables
B.
system
C.
process
D.
using
Submit your test now to view the Results and Statistics with answer explanation.