JavaScript Language | 1‐Hour‐Test 1


Instruction

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

1.

The development environment offers which standard construct for data validation

A.
Super controlled loop constructs
B.
Case sensitivity check
C.
Validation constructs
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

All these facilities are available in JavaScript. Additionally, all development environments provide syntax to create and use memory variables, constants, and functions.

2.

Which attribute is used to specify that the script is executed when the page has finished parsing ( only for external scripts )

A.
parse
B.
async
C.
defer
D.
type

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

In order to load a page, the browser must parse the contents of all script tags, which adds additional time to the page load. By minimizing the amount of JavaScript needed to render the page, and deferring parsing of unneeded JavaScript until it needs to be executed, you can reduce the initial load time of your page.

3.

A proper scripting language is a

A.
High level programming language
B.
Assembly level programming language
C.
Machine level programming language
D.
Low level programming language

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

4.

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:

JavaScript code is as easy to be implemented and run. It can be called by using a function or a method.

5.

When there is an indefinite or an infinity value during an arithmetic value computation, javascript

A.
Prints an exception error
B.
Prints an overflow error
C.
Displays “Infinity”
D.
Prints the value as such

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

When the result of a numeric operation is larger than the largest representable number (overflow), the result is a special infinity value, which JavaScript prints as Infinity. Similarly, when a negative value becomes larger than the largest representable negative number, the result is negative infinity, printed as -Infinity. The infinite values behave as you would expect: adding, subtracting, multiplying, or dividing them by anything results in an infinite value (possibly with the sign reversed).

6.

Assume that we have to convert “false” that is a non-string to string. The command that we use is (without invoking the “new” operator)

A.
false.toString()
B.
String(false)
C.
String newvariable=”false”
D.
Both a and b

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

A non-string can be converted in two ways without using a new operator. false.toString() and String(false).

7.

Consider the following snippet code

var string1 =123;
var intvalue = 123;
alert( string1 + intvalue );
The result would be

A.
123246
B.
246
C.
123123
D.
Exception

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

8.

The JavaScript’s syntax calling ( or executing ) a function or method is called

A.
Primary expression
B.
Functional expression
C.
Invocation expression
D.
Property Access Expression

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

An invocation expression is JavaScript’s syntax for calling (or executing) a function or method. It starts with a function expression that identifies the function to be called.

9.

“An expression that can legally appear on the left side of an assignment expression.” is a well known explanation for variables, properties of objects, and elements of arrays. They are called

A.
Properties
B.
Prototypes
C.
Lvalue
D.
Definition

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

L-value is a historical term that means “an expression that can legally appear on the left side of an assignment expression.” In JavaScript, variables, properties of objects, and elements of arrays are lvalues.

10.

JavaScript is a _______________ language

A.
Object-Oriented
B.
High-level
C.
Assembly-language
D.
Object-Based

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

JavaScript is not a full-blown OOP (Object-Oriented Programming) language, such as Java or PHP, but it is an object-based language.

11.

A statement block is a

A.
conditional block
B.
block that contains a single statement
C.
Both a and b
D.
block that combines multiple statements into a single compound statement

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

A statement block is a block that combines more than one statements into a single compound statement for ease.

12.

The enumeration order becomes implementation dependent and non-interoperable if

A.
If the object inherits enumerable properties
B.
The object does not have the properties present in the integer array indices
C.
The delete keyword is never used
D.
Object.defineProperty() is not used

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

13.

Consider the following code snippet

function printArray(a)

{

     var len = a.length, i = 0;

     if (len == 0)

       console.log("Empty Array");

     else

     {

         do

         {

             console.log(a[i]);

         }

while (++i < len);

     }

}

What does the above code result?

A.
Prints the numbers in the array in order
B.
Prints the numbers in the array in the reverse order
C.
Prints 0 to the length of the array
D.
Prints “Empty Array”

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The do/while loop is less commonly used when compared to the while loop. Here, it prints from the array in the given order.

14.

One of the special feature of an interpreter in reference with the for loop is that

A.
Before each iteration, the interpreter evaluates the variable expression and assigns the name of the property
B.
The iterations can be infinite when an interpreter is used
C.
The body of the loop is executed only once
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Before each iteration, the interpreter evaluates the variable expression and assigns the name of the property (a string value) to it.

15.

Among the keywords below, which one is not a statement?

A.
debugger
B.
with
C.
if
D.
use strict

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

use strict is a directive introduced in ECMAScript5. Directives are not statements because it does not include any language keywords. Also, it can appear only at the start of a script or at the start of a function body, before any real statemenst have appeared.

16.

The unordered collection of properties, each of which has a name and a value is called

A.
String
B.
Object
C.
Serialized Object
D.
All of the above

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

An object is an unordered collection of properties, each of which has a name and a value. Property names are strings, so we can say that objects map strings to values.

17.

Consider the below given syntax

book[datatype]=assignment_value;


In the above syntax, the datatype within the square brackets must be

A.
An integer
B.
A String
C.
An object
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

When using square bracket notation, the expression inside the square brackets must evaluate to a sting or a value that can be converted to a string.

18.

The basic purpose of the toLocaleString() is to

A.
return a localised object representation
B.
return a parsed string
C.
return a local time in the string format
D.
return a localized string representation of the object

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

19.

Consider the code snippet given below

var count = [1,,3];

What is the observation made?

A.
The omitted value takes “undefined”
B.
This results in an error
C.
This results in an exception
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

If you omit a value from an array literal, the omitted element is given the value.

20.

What will happen if reverse() and join() methods are used simultaneously ?

A.
Reverses and stores in the same array
B.
Reverses and concatenates the elements of the array
C.
Reverses
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The reverse() followed by a join() will reverse the respective array and will store the reversed array in the memory.

21.

The method or operator used to identify the array is

A.
isarrayType()
B.
==
C.
===
D.
typeof

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The typeof property is used to identify the array type.

22.

The function definitions in JavaScript begins with

A.
Identifier and Parantheses
B.
Return type and Identifier
C.
Return type, Function keyword, Identifier and Parantheses
D.
Identifier and Return type

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The function definitions begin with the keyword function followed by an identifier that names the function and a pair of parantheses around a comma-separated list of zero or more identifiers.

23.

What will happen if a return statement does not have an associated expression?

A.
It returns the value 0
B.
It will throw an exception
C.
It returns the undefined value
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

If the return statement does not have an associated expression, it returns the undefined value.

24.

Consider the following code snippet

o.m(x,y);

Which is an equivalent code for the above code snippet?

A.
o.m(x) && o.m(y);
B.
o["m"](x,y);
C.
o(m)["x","y"];
D.
o.m(x && y);

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Another way to write o.m(x,y) is o[“m”](x,y).

25.

Consider the following code snippet :

var grand_Total=eval("10*10+5");

The output for the above statement would be :

A.
10*10+5
B.
105 as a string
C.
105 as an integer value
D.
Exception is thrown

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Even if the string value passed as a parameter to eval does represent a numeric value the use of eval() results in an error being generated.

26.

Consider the following code snippet :

var string2Num=parseInt("123xyz");

The result for the above code snippet would be :

A.
123
B.
123xyz
C.
Exception
D.
NaN

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The parseInt() function returns the first integer contained in the string or 0 if the string does not begin with an integer.

1.

Consider the following code snippet :

function constfuncs()

{

    var funcs = [];

    for(var i = 0; i < 10; i++)

        funcs[i] = function() { return i; };

    return funcs;

}

var funcs = constfuncs();

funcs[5]()

What does the last statement return ?

A.
9
B.
0
C.
10
D.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The code above creates 10 closures, and stores them in an array. The closures are all defined within the same invocation of the function, so they share access to the variable i. When constfuncs() returns, the value of the variable i is 10, and all 10 closures share this value. Therefore, all the functions in the returned array of functions return the same value.

28.

What kind of scoping does JavaScript use?

A.
Literal
B.
Lexical
C.
Segmental
D.
Sequential

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Like most modern programming languages, JavaScript uses lexical scoping. This means that functions are executed using the variable scope that was in effect when they were defined, not the variable scope that is in effect when they are invoked.

29.

Which of the following uses a lot of CPU cycles?

A.
GUI
B.
Statically generated graphics
C.
Dynamically generated graphics
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Dynamically generating graphics from real-time data uses a lot of CPU cycles.

30.

Which of the algorithmiJavaScript Languages is lexical scoping standardized in?

A.
Ada
B.
Pascal
C.
Modula2
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Lexical scoping is standardized in all algorithmiJavaScript Languages (ALGOL), such as Ada, Pascal, and Modula2. Additionally, it is used in modern functional languages like ML and Haskel.

31.

The behaviour of the instances present of a class inside a method is defined by

A.
Method
B.
Classes
C.
Interfaces
D.
Classes and Interfaces

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The behaviour of the instance of a class is defined by the class and is shared by all instances.

32.

The meaning for Augmenting classes is that

A.
objects inherit prototype properties even in dynamic state
B.
objects inherit prototype properties only in dynamic state
C.
objects inherit prototype properties in static state
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

JavaScript’s prototype-based inheritance mechanism is dynamic: an object inherits properties from its prototype, even if the prototype changes after the object is created. This means that we can augment JavaScript classes simply by adding new methods to their prototype objects.

33.

The method that can be used to create new properties and also to modify the attributes of existing properties is

A.
Object.defineProperty()
B.
Object.defineProperties()
C.
Both a and b
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

When used to define new properties, any attributes you omit default to false. Therefore, both Object.defineProperty() and Object.defineProperties() can be used to create and modify the attributes.

34.

The four kinds of class members are

A.
Instance methods, Instance fields, Static method, Dynamic method
B.
Instance fields, Instance methods, Class fields, Class methods
C.
Instance fields, Non-instance fields, Dynamic methods, Global methods
D.
Global methods, Local methods, Dynamic methods, Static methods

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The four kinds of class members are Instance fields, Instance methods, Class fields, Class methods.

35.

The class that represents the regular expressions is

A.
RegExpObj
B.
RegExpClass
C.
RegExp
D.
StringExp

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The JavaScript RegExp class represents regular expressions, and both string and RegExp define methods that use regular expressions.

36.

You can refresh the webpage in JavaScript by using

A.
window.reload
B.
location.reload
C.
window.refresh
D.
page.refresh

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

One can refresh the webpage in JavaScript by using location.reload.

37.

The functions provide() and require() of Dojo toolkit and Google’s Closure library are used for

A.
declaring and loading modules
B.
loading and declaring modules
C.
Both a and b
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Both the Dojo toolkit and Google’s Closure library define provide() and require() functions for declaring and loading modules.

38.

The scope of a function is also called as

A.
The function’s scope
B.
Module function
C.
Modulated function
D.
Private function

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The scope of a function can be used as a private namespace for a module. Therefore, the scope of a function is called a module function.

39.

What can be done in order to avoid creation of global variables in JavaScript?

A.
To use a method that defines all the variables
B.
To use an object that has the reference to all the variables
C.
To use an object as its namespace
D.
To use global functions

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

One way for a module to avoid the creation of global variables is to use an object as its namespace. Instead of defining global functions and variables, it stores the functions and values as properties of an object (which may be referenced to a global variable).

40.

The ‘$’ present in the RegExp object is called a

A.
character
B.
matcher
C.
metacharacter
D.
metadata

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The ‘S’ is a special metacharacter that matches the end of a string.

41.

What will be the result when non greedy repetition is used on the pattern /a+?b/ ?

A.
Matches the letter b preceded by the fewest number of a’s possible
B.
Matches the letter b preceded by any number of a
C.
Matches letter a preceded by letter b, in the stack order
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Using non greedy repetition may not always produce the results you expect. /a+?b/ matches the letter b preceded by the fewest number of a’s possible.

42.

What would be the result of the following statement in JavaScript using regular expression methods ?

A.
Returns [“123″”456″”789”]
B.
Returns [“123″,”456″,”789”]
C.
Returns [1,2,3,4,5,6,7,8,9]
D.
Throws an exception

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The split() method can take regular expressions as its arguments. The split() method generally breaks the string on which it is called into an array of substrings, using the argument as a separator.

44.

Which is the subset that is a secure container designed for the purpose of safely running untrusted JavaScript?

A.
Sandbox
B.
The Good Parts
C.
Both a and b
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

There is a larger class of subsets that have been designed for the purpose of safely running untrusted JavaScript in a secure container or “sandbox”.

45.

Which is the subset that transforms web content into secure modules that can be safely hosted on a web page?

A.
Microsoft Web Sandbox
B.
ADsafe
C.
Caja
D.
dojox.secure

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Caja is Google’s open-source secure subset. Caja (Spanish for “box”) defines two language subsets. Cajita (“little box”) is a narrow subset like that used by ADsafe and dojox.secure. Valija (“suitcase” or “baggage”) is a much broader language that is close to regular ECMAScript 5 strict mode (with the removal of eval()). Caja itself is the name of the compiler that transforms (or “cajoles”) web content (HTML, CSS, and JavaScript code) into secure modules that can be safely hosted on a web page without being able to affect the page as a whole or other modules on the page.

46.

Consider the following code snippet

const pi=3.14;

var pi=4;

console.log(pi);

What will be the output for the above code snippet?

A.
This will flash an error
B.
Prints 4
C.
Prints 3.14
D.
Ambiguity

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The above code snippet will flash an error. Attempts to alter the value or re-declaration causes errors.

47.

Consider the following code snippet

console.log(p)
If p is not defined, what would be the result or type of error?

A.
Zero
B.
Null
C.
ReferenceError
D.
ValueNotFoundError

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

In the above code snippet, p is not defined. Hence, it gives a ReferenceError.

48.

Which method of the iterable object returns an iterator object for the collection?

A.
iterator()
B.
_iterator_()
C.
_iteration_()
D.
_return_iterator_()

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

An iterable object represents a collection of values that can be iterated. An iterable object must define a method named __iterator__() (with two underscores at the start and end of the name) which returns an iterator object for the collection.

49.

Consider the following code snippet

let succ = function(x) x+1, yes = function() true, no = function() false;
What convenience does the above code snippet provide?

A.
Functional behaviour
B.
Modular behaviour
C.
No convenience
D.
Shorthand expression

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The functions defined in this way behave exactly like functions defined with curly braces and the return keyword.

50.

When will the finally block be called?

A.
When there is no exception
B.
When the catch doesnot match
C.
Both a and b
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

A finally block is called after try-catch execution.

51.

What is the code required to delete all “weight” tags?

A.
delete weight(pt).all;
B.
delete pt.element[all];
C.
delete pt;
D.
delete pt..weight;

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Removing attributes and tags is very easy with the standard delete operator :

delete pt..weight; //delete all <weight> tags

52.

What are the events generated by the Node objects called?

A.
generators
B.
emitters
C.
dispatchers
D.
highevents

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Node objects that generate events (known as event emitters) define an on() method for registering handlers.

53.

Which of the following is an event emitter?

A.
once
B.
process
C.
listeners
D.
on

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The process object is an event emitter. The Node defines other important globals under the process namespaces that contain properties of that object like version, argv, env, pid,getuid(), cwd(), chdir() and exit().

54.

What will be the return value of the write() method when the Node cannot write the data immediately and has to buffer it internally?

A.
0
B.
1
C.
True
D.
False

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The write() method never blocks. If Node cannot write the data immediately and has to buffer it internally, the write() method returns false.

55.

Which are the forms of client-side storage?

A.
Web Databases
B.
FileSystem API
C.
Offline Web Applications
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The various forms of client-side storage are web databases, filesystem API, Offline web applications and cookies.

56.

Which is the most appropriate database for developers requiring huge amount of data?

A.
Database
B.
Datawarehouse
C.
Web databases
D.
Access

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Developers who need to work with really huge amounts of data like to use databases, and the most recent browsers have started to integrate client-side database functionality into their browsers.

57.

Which is the function used to store a value?

A.
setItem()
B.
set()
C.
storeItem()
D.
store()

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

To store a value, pass the name and value to setItem().

58.

Which of the following is a way of embedding Client-side JavaScript code within HTML documents?

A.
From javascript:encoding
B.
External file specified by the src attribute of a “script” tag
C.
Both a and b
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The Client-side JavaScript code is embedded within HTML documents in four ways :
Inline, between a pair of “script” tags
From an external file specified by the src attribute of a “script” tag
In an HTML event handler attribute, such as onclick or onmouseover
In a URL that uses the special javascript: protocol.

59.

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. [/expand].

60.

The language is commonly used to

A.
Specify the user’s language
B.
Specify the language going to be scripted
C.
No longer in use
D.
Specify the programmer’s favorable language

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The language attribute is deprecated and should no longer be used.


Feedback:

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