JavaScript Language | 30 Minute Test


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.

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.


Feedback:

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