Javascript Mock Test


Advertisements

This section presents you various set of Mock Tests related to Javascript Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

Javascript Mock Test II

Q 1 - Which built-in method calls a function for each element in the array?

A - while()

B - loop()

C - forEach()

D - None of the above.

Answer : C

Explanation

forEach() method calls a function for each element in the array.

Q 2 - Which built-in method returns the index within the calling String object of the first occurrence of the specified value?

A - getIndex()

B - location()

C - indexOf()

D - None of the above.

Answer : C

Explanation

indexOf() method returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.

Q 3 - Which built-in method returns the length of the string?

A - length()

B - size()

C - index()

D - None of the above.

Answer : A

Explanation

length() method returns the length of the string.

Q 4 - Which built-in method removes the last element from an array and returns that element?

A - last()

B - get()

C - pop()

D - None of the above.

Answer : C

Explanation

pop() method removes the last element from an array and returns that element.

Q 5 - Which built-in method adds one or more elements to the end of an array and returns the new length of the array?

A - last()

B - put()

C - push()

D - None of the above.

Answer : C

Explanation

push() method adds one or more elements to the end of an array and returns the new length of the array.

Q 6 - Which built-in method reverses the order of the elements of an array?

A - changeOrder(order)

B - reverse()

C - sort(order)

D - None of the above.

Answer : B

Explanation

reverse() method reverses the order of the elements of an array -- the first becomes the last, and the last becomes the first.

Q 7 - Which built-in method sorts the elements of an array?

A - changeOrder(order)

B - order()

C - sort()

D - None of the above.

Answer : C

Explanation

sort() method sorts the elements of an array.

Q 8 - Which built-in method returns the characters in a string beginning at the specified location?

A - substr()

B - getSubstring()

C - slice()

D - None of the above.

Answer : A

Explanation

substr() method returns the characters in a string beginning at the specified location through the specified number of characters.

Q 9 - Which built-in method returns the calling string value converted to lower case?

A - toLowerCase()

B - toLower()

C - changeCase(case)

D - None of the above.

Answer : A

Explanation

toLowerCase() method returns the calling string value converted to lower case.

Q 10 - Which built-in method returns the calling string value converted to upper case?

A - toUpperCase()

B - toUpper()

C - changeCase(case)

D - None of the above.

Answer : A

Explanation

toUpperCase() method returns the calling string value converted to upper case.

Q 11 - Which built-in method returns the string representation of the number's value?

A - toValue()

B - toNumber()

C - toString()

D - None of the above.

Answer : C

Explanation

toString() method returns the string representation of the number's value.

Q 12 - All user-defined objects and built-in objects are descendants of an object called Object?

A - true

B - false

Answer : A

Explanation

All user-defined objects and built-in objects are descendants of an object called Object.

Answer : B

Explanation

var book = new Object(); creates an object.

Q 14 - Which of the following function of Number object forces a number to display in exponential notation?

A - toExponential()

B - toFixed()

C - toPrecision()

D - toLocaleString()

Answer : A

Explanation

toExponential(): Forces a number to display in exponential notation, even if the number is in the range in which JavaScript normally uses standard notation.

Q 15 - Which of the following function of Number object formats a number with a specific number of digits to the right of the decimal?

A - toExponential()

B - toFixed()

C - toPrecision()

D - toLocaleString()

Answer : B

Explanation

toFixed() − Formats a number with a specific number of digits to the right of the decimal.

Q 16 - Which of the following function of Number object returns a string value version of the current number in a format that may vary according to a browser's locale settings.?

A - toExponential()

B - toFixed()

C - toLocaleString()

D - toString()

Answer : C

Explanation

toLocaleString() − Returns a string value version of the current number in a format that may vary according to a browser's locale settings.

Q 17 - Which of the following function of Number object defines how many total digits to display of a number?

A - toExponential()

B - toFixed()

C - toLocaleString()

D - toPrecision()

Answer : D

Explanation

toPrecision() − Defines how many total digits (including digits to the left and right of the decimal) to display of a number.

Q 18 - Which of the following function of Number object returns a string value version of the current number?

A - toString()

B - toFixed()

C - toLocaleString()

D - toPrecision()

Answer : A

Explanation

toString() − Returns a string value version of the current number.

Q 19 - Which of the following function of Number object returns the number's value?

A - toString()

B - valueOf()

C - toLocaleString()

D - toPrecision()

Answer : B

Explanation

valueOf() − Returns the number's value.

Q 20 - Which of the following function of Boolean object returns a string containing the source of the Boolean object?

A - toSource()

B - valueOf()

C - toString()

D - None of the above.

Answer : A

Explanation

toSource() − Returns a string containing the source of the Boolean object; you can use this string to create an equivalent object.

Q 21 - Which of the following function of Boolean object returns the primitive value of the Boolean object?

A - toSource()

B - valueOf()

C - toString()

D - None of the above.

Answer : B

Explanation

valueOf() − Returns the primitive value of the Boolean object.

Q 22 - Which of the following function of Boolean object returns a string of either 'true' or 'false' depending upon the value of the object?

A - toSource()

B - valueOf()

C - toString()

D - None of the above.

Answer : C

Explanation

toString() − Returns a string of either 'true' or 'false' depending upon the value of the object.

Q 23 - Which of the following function of String object returns the character at the specified index?

A - charAt()

B - charCodeAt()

C - concat()

D - indexOf()

Answer : A

Explanation

charAt() − Returns the character at the specified index.

Q 24 - Which of the following function of String object returns a number indicating the Unicode value of the character at the given index?

A - charAt()

B - charCodeAt()

C - concat()

D - indexOf()

Answer : B

Explanation

charCodeAt() − Returns a number indicating the Unicode value of the character at the given index.

Q 25 - Which of the following function of String object combines the text of two strings and returns a new string?

A - add()

B - merge()

C - concat()

D - append()

Answer : C

Explanation

concat() − Combines the text of two strings and returns a new string.

Answer Sheet

Question Number Answer Key
1 C
2 C
3 A
4 C
5 C
6 B
7 C
8 A
9 A
10 A
11 C
12 A
13 B
14 A
15 B
16 C
17 D
18 A
19 B
20 A
21 B
22 C
23 A
24 B
25 C
javascript_questions_answers.htm
Advertisements