Professional Documents
Culture Documents
UNIT-5 Mcqs
UNIT-5 Mcqs
A - You should not use any of the JavaScript reserved keyword as variable name.
B - JavaScript variable names should not start with a numeral (0-9).
Answer : C
Explanation
Both of the above options are correct.
Answer : C
Explanation
A function in JavaScript can be either named or anonymous.
3. 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()
Answer : C
Explanation
push() method adds one or more elements to the end of an array and returns the new length of
the array.
4. 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.
5. 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.
6. Which of the following function of String object returns the characters in a string beginning
at the specified location through the specified number of characters?
A - slice()
B - split()
C - substr()
D - search()
Answer : C
Explanation
substr() − Returns the characters in a string beginning at the specified location through the
specified number of characters.
7. Which of the following function of String object creates a string to be displayed in a big font
as if it were in a <big> tag?
A - anchor()
B - big()
C - blink()
D - italics()
Answer : B
Explanation
big() − Creates a string to be displayed in a big font as if it were in a <big> tag.
8. Which of the following function of String object creates an HTML hypertext link that
requests another URL?
A - link()
B - sub()
C - sup()
D - small()
Answer : A
Explanation
link() − Creates an HTML hypertext link that requests another URL.
9. Which of the following function of Array object removes the last element from an array and
returns that element?
A - pop()
B - push()
C - join()
D - map()
Answer : A
Explanation
pop() − Removes the last element from an array and returns that element.
10. Which of the following function of Array object returns a string representing the array and
its elements?
A - toSource()
B - sort()
C - splice()
D - toString()
Answer : D
Explanation
toString() − Returns a string representing the array and its elements.
11. The general definition of a(n) ____ is a set of linked documents with shared attributes,
such as related topics, a similar design, or a shared purpose.
a. index
b. website
c. Internet
d. Homepage
ANSWER: website
12. To enable data tainting, the end user sets the _________ environment variable.
a. ENABLE_TAINT
b. MS_ENABLE_TAINT
c. NS_ENABLE_TAINT
d. ENABLE_TAINT_NS
ANSWER: NS_ENABLE_TAINT
When the above web page is loaded into a browser, what will happen?
a. The body of the web page will not contain any text
b. The body of the web page will contain the text “hello world” as an H1 heading
c. The background color of the web page will be green
d. document.write("<h1> hello world </h1 >”); is a comment.
ANSWER: The body of the web page will not contain any text
16. The _______ method of an Array object adds and/or removes elements from an array.
a. Reverse
b. Shift
c. Slice
d. Splice
ANSWER: Splice
23. _____ JavaScript statements embedded in an HTML page can respond to user events
such as mouse-clicks, form input, and page navigation.
A. Client-side
B. Server-side
C. Local
D. Native
Ans: A
28. ______ tag is an extension to HTML that can enclose any number of JavaScript
statements.
A. <SCRIPT>
B. <BODY>
C. <HEAD>
D. <TITLE>
Ans: A
30. Which of the following attribute can hold the JavaScript version?
A. LANGUAGE
B. SCRIPT
C. VERSION
D. None of the above
Ans: A
31. What is the correct JavaScript syntax to write "Hello World"?
A. System.out.println("Hello World")
B. println ("Hello World")
C. document.write("Hello World")
D. response.write("Hello World")
Ans: C
32. Which of the following way can be used to indicate the LANGUAGE attribute?
A. <LANGUAGE="JavaScriptVersion">
B. <SCRIPT LANGUAGE="JavaScriptVersion">
C. <SCRIPT LANGUAGE="JavaScriptVersion"> JavaScript statements…</SCRIPT>
D. <SCRIPT LANGUAGE="JavaScriptVersion"!> JavaScript statements…</SCRIPT>
Ans: C
36. Which of the following navigator object properties is the same in both Netscape and
IE?
A. navigator.appCodeName
B. navigator.appName
C. navigator.appVersion
D. None of the above
Ans: A
39. If para1 is the DOM object for a paragraph, what is the correct syntax to change the
text within the paragraph?
A. "New Text"?
B. para1.value="New Text";
C. para1.firstChild.nodeValue= "New Text";
D. para1.nodeValue="New Text";
Ans: B
40. JavaScript entities start with _______ and end with _________.
A. Semicolon, colon
B. Semicolon, Ampersand
C. Ampersand, colon
D. Ampersand, semicolon
Ans: D
45. ______method evaluates a string of JavaScript code in the context of the specified
object.
A. Eval
B. ParseInt
C. ParseFloat
D. Efloat
Ans: A
46. Which of the following event fires when the form element loses the focus: <button>,
<input>, <label>, <select>, <textarea>?
A. onfocus
B. onblur
C. onclick
D. ondblclick
Ans: B
51. To set up the window to capture all Click events, we use which of the following
statement?
A. window.captureEvents(Event.CLICK);
B. window.handleEvents (Event.CLICK);
C. window.routeEvents(Event.CLICK );
D. window.raiseEvents(Event.CLICK );
Ans: A
54. To enable data tainting, the end user sets the _________ environment variable.
A. ENABLE_TAINT
B. MS_ENABLE_TAINT
C. NS_ENABLE_TAINT
D. ENABLE_TAINT_NS
Ans: C
55. A ________ object is a reference to one of the classes in a Java package, such as
netscape.javascript .
A. JavaArray
B. JavaClass
C. JavaObject
D. JavaPackage
Ans: B