JavaScript MCQ Questions with Answers – Part 4

JavaScript MCQ Techhyme Part 4

JavaScript is among the most powerful and flexible programming languages of the web. It powers the dynamic behavior on most websites, including this one.

Also Read:

This article contains 50 JavaScript Multiple-Choice Questions with Answers. These JavaScript MCQs are written for beginners as well as advanced, practice these MCQs to enhance and test the knowledge of JavaScript. You will have to read all the given answers.

1. True or False. DHTML combines CSS and JavaScript.

A. True
B. False

Correct Answer – A

2. With DHTML you can

A. Place objects in absolute positions on the screen
B. Display objects on different layers
C. Change the content of the web page without reloading it
D. All of the above

Correct Answer – D

3. The standard for DHTML is defined in

A. HTML 4.0
B. HTML 3.0
C. HTML 4.5
D. None of the above

Correct Answer – A

4. A class definition begins with a

A. Pound sign
B. Period
C. Class name
D. ID name

Correct Answer – B

5. An id begins with a

A. Pound sign
B. Period
C. Class name
D. ID name

Correct Answer – A

6. You apply a class by

A. Assigning the class name to the class attribute
B. Assigning the class name to the id attribute
C. Calling the class name from anywhere in the web page
D. All of the above

Correct Answer – A

7. True or False. DHTML replaces JavaScript.

A. True
B. False

Correct Answer – B

8. True or False. DHTML can make a web page work like a desktop application that contains features found in multimedia products.

A. True
B. False

Correct Answer – A

9. True or False. Rules are contained in a class definition.

A. True
B. False

Correct Answer – A

10. Classes are defined within

A. <div>
B. <style>
C. <p>
D. None of the above

Correct Answer – B

11. What is assigned an action to perform when the mouse cursor leaves an object?

A. onmouseout event
B. onmouseover event
C. onmouseout attribute
D. onmouseover attribute

Correct Answer – C

12. If the document. Layers value is null

A. Then the visitor is using the Netscape browser
B. Then the visitor is using the Internet Explorer browser
C. Then a bot is accessing the web page
D. None of the above

Correct Answer – B

13. True or False. All images on a web page are reflected in the document .images array.

A. True
B. False

Correct Answer – A

14. What attribute(s) can be used to change the source of a child window from a JavaScript?

A. source
B. src
C. parent.frame.location.source
D. parent.frame.location.href

Correct Answer – B

15. True or False. All windows must have the standard browser toolbar.

A. True
B. False

Correct Answer – B

16. What event occurs when a person highlights text in a text field?

A. onblur
B. onfocus
C. onselect
D. onchange

Correct Answer – C

17. True or False. The index of the last element in the string array is not the same value as the string length.

A. True
B. False

Correct Answer – A

18. What attribute is used to load a web page from within a JavaScript?

A. location
B. upload
C. dnload
D. None of the above

Correct Answer – A

19. What is the purpose of the first parameter of the set Timeout () function?

A. Sets the timeout period in milliseconds
B. Sets the timeout period in seconds
C. Identifies the function that is to be called at the conclusion of the timeout period
D. Identifies the function that called the timeout period

Correct Answer – C

20. True or False. Values passed to a function must correspond to the data type of arguments in the function definition.

A. True
B. False

Correct Answer – A

21. What is the purpose of else in an if…else statement?

A. Contains statements that are executed if the conditional expression is true
B. Defines another conditional expression the browser evaluates if the first conditional expression is false
C. Contains statements that are executed if the conditional expression is false
D. Used to nest an if statement

Correct Answer – B

22. What is happening in this expression: a++?

A. The value of a is increased by 2.
B. The value of a is increased by 1.
C. The value of a is multiplied by itself.
D. Nothing. This is not a valid JavaScript expression.

Correct Answer – B

23. Which of the following in an e-mail can you generate from a JavaScript?

A. TO
B. CC
C. BCC
D. All of the above

Correct Answer – D

24. How do you load all banners before the first banner is displayed?

A. Use the load () function.
B. Use the loadMem () function.
C. Store banners in an array when the web page loads.
D. Store banners in an array after the web page loads

Correct Answer – C

25. True or False. You do not specify the name of the frame whenever you want to reference the contents of the frame.

A. True
B. False

Correct Answer – B

26. You scroll a window by calling

A. goto
B. down or up
C. down
D. scrollTo()

Correct Answer – D

27. The second argument in the substr () method indicates

A. The position of the last character that is copied into the substring
B. The number of characters that are to be copied from the string to the substring
C. The position of the character preceding the last character that is copied into the substring
D. The position of the character preceding the last character in the substring

Correct Answer – C

28. How many elements are there in this array? Products = new Array (‘Soda’,’Beer’,’Pizza’)

A. 2
B. 3
C. 4
D. None

Correct Answer – B

29. What does the && operator do?

A. Evaluates true if the expressions on its left and right are both true
B. Evaluates true if the expression on its left or on its right is true
C. Evaluates true if neither expression on its left nor right are true
D. Combines the expression on its right with the expression on its left

Correct Answer – A

30. The foreground color of a document is a type of

A. Object
B. Method
C. Property
D. Variable

Correct Answer – C

31. True or False. A period must separate arguments in a function definition.

A. True
B. False

Correct Answer – B

32. An intrinsic function

A. Must be defined in the <head> tag
B. Must be defined in the <body> tag
C. Must be defined by the programmer either to submit the form or reset the form
D. Is not defined by the programmer

Correct Answer – D

33. You can enable a person to resize your new window by

A. Setting resizable to 1
B. Setting resizable to 0
C. Setting the menubar to 1
D. Setting the menubar to 0

Correct Answer – A

34. You can create a rollback of an image by reacting to which event?

A. onmouse event
B. onmouserollback event
C. onmouserestore event
D. None of the above

Correct Answer – D

35. True or False. Options selected from a pull-down menu can be validated by a JavaScript.

A. True
B. False

Correct Answer – A

36. True or False. A regular expression can be used to reformat text.

A. True
B. False

Correct Answer – A

37. The Submit button is a type of

A. Object
B. Method
C. Property
D. Variable

Correct Answer – A

38. What is an alias for computer memory reserved by your JavaScript?

A. Operator
B. Variable name
C. Literal value
D. Variable type

Correct Answer – B

39. True or False. The! = operator makes a true false.

A. True
B. False

Correct Answer – B

40. What is the purpose of if in an if…else statement?

A. Contains statements that are executed if the conditional expression is true
B. Defines another conditional expression the browser evaluates if the first conditional expression is false
C. Contains statements that are executed if the conditional expression is false
D. Used to nest an if statement

Correct Answer – A

41. What method is used to place a new element at the end of an array?

A. push()
B. pop()
C. reverse()
D. shift()

Correct Answer – A

42. A float is

A. An integer
B. A whole number
C. A decimal value
D. A Unicode number

Correct Answer – C

43. True or False. You can delete a cookie.

A. True
B. False

Correct Answer – A

44. Which special character is used to tell the browser to start at the beginning of a string in a regular expression?

A. $
B. *
C. ^
D. []

Correct Answer – C

45. What frame receives focus by default?

A. First frame that is built
B. Last frame that is built
C. No frame has focus
D. None of the above

Correct Answer – B

46. The value of document.images is null if the browser does not support the image object.

A. True
B. False

Correct Answer – B

47. What special character do you use to search for any letter, number, or the underscore using a regular expression?

A. \w
B. \W
C. w
D. W

Correct Answer – A

48. You can bring a new window to the top of other windows by calling

A. upper()
B. up()
C. focus()
D. next()

Correct Answer – A

49. What event occurs when a person leaves text in a text field?

A. onblur
B. onfocus
C. onselect
D. onchange

Correct Answer – A

50. A variable is out of scope when

A. The statement that calls a function ignores the value returned by the function
B. The variable cannot be accessed by a statement
C. A variable isn’t defined in a function
D. When a variable is passed to a function

Correct Answer – B