Others



JavaScript MCQ (Mulitple Choice Questions and Answers)


  1. What is JavaScript?

    1. scripting language

    2. assembly language

    3. compiled language

    4. None of the mentioned

  2. Which one of the following also known as Conditional Expression?

    1. Alternative to if-else

    2. Switch statement

    3. If-then-else statement

    4. immediate if

  3. The "function" and " var" are known as?

    1. Keywords

    2. Data types

    3. Declaration statements

    4. Prototypes

  4. A collection of elements of the same data type which may either in order or not, is called

    1. String

    2. Array

    3. Serialized Object

    4. Object

  5. A set of unordered properties that, has a name and value is called

    1. String

    2. Array

    3. Serialized Object

    4. Object

  6. Which HTML element is used to put the JavaScript code?

    1. <javascript>

    2. <js>

    3. <scripting>

    4. <script>

  7. Which of the following is not a JavaScript Data Types?

    1. Boolean

    2. String

    3. Float

    4. Number

  8. Which of the following syntax can be used to write "Hello World" in an alert box?

    1. alertBox("Hello World");

    2. msgBox("Hello World");

    3. alert("Hello World");

    4. msg("Hello World");

  9. Which of the following is the correct way to write a comment in JavaScript code?

    1. //This is a comment

    2. /*This is a comment*/

    3. $This is a comment$

    4. **This is a comment**

  10. Which of the following JavaScript operator is used to assign a value to a variable based on some condition?

    1. Assignment operator

    2. Bitwise Operator

    3. Conditional operator

    4. Logical Operator

  11. Which of the following is Pop up box in JavaScript??

    1. Alert

    2. Prompt

    3. Confirm

    4. All of the above

  12. Which of the following is the correct statement of WHILE loop start?

    1. while (i <= 15)

    2. while (i=0; i <= 15; i++)

    3. while i = 1 to 15

    4. None of These

  13. What are the different types of errors in JavaScript?

    1. Syntax errors

    2. Run time errors

    3. Logical Errors

    4. All of the above

  14. Which of the following built-in method is used to remove the last element from an array and return that element?

    1. last()

    2. pop()

    3. get()

    4. None of the above

  15. What is the correct syntax for referring to an external script called : script.js"?

    1. <script href="script.js">

    2. <script name="script.js">

    3. <script src="script.js">

    4. None of the above

  16. Which of the following is a error type in JavaScript?

    1. Missing of Bracket

    2. Division by zero

    3. Syntax error

    4. Missing of semicolons

  17. JavaScript ignores?

    1. spaces

    2. tabs

    3. new lines

    4. All of the above

  18. Can you access Cookie using javascript?

    1. True

    2. False

  19. Which built-in method sorts the elements of an array?

    1. changeOrder(order)

    2. order()

    3. sort()

    4. None of the above

  20. Which of the following function of String object returns the character at the specified index?

    1. charAt()

    2. charCodeAt()

    3. concat()

    4. indexOf()

  21. Which of the following function of String object splits a String object into an array of strings by separating the string into substrings?

    1. slice()

    2. split()

    3. replace()

    4. search()

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

    1. if

    2. with

    3. else

    4. use strict

  23. Which of them is not the looping structures in JavaScript?

    1. for

    2. while

    3. forwhile

    4. dowhile

  24. JavaScript is designed for following purpose

    1. to style HTML pages

    2. to execute Queries related to databases on a server

    3. to add interactivity to html pages

    4. All of the above

  25. Which of the following is not a built-in function in JavaScript?

    1. search()

    2. concat()

    3. add()

  26. Javascript string using double quotes is exactly the same as a string using single quotes?

    1. True

    2. False

  27. In JavaScript, Arrays are data type. State True or False

    1. True

    2. False

  28. Which of the following method checks if its argument is not a number?

    1. isNaN()

    2. nonNaN()

    3. NaN()

    4. None of the above

  29. Which method is used to add and/or remove elements from an array in Javascript?

    1. Reverse

    2. Shift

    3. Slice

    4. Splice

  30. JavaScript can be written

    1. directly into JS file and included into HTML

    2. directly on the server page

    3. directly into HTML pages

    4. directly into the css file

  31. How to get a particular value using the tagged name?

    1. getElementbyID()

    2. getElementsbyName()

    3. getElementsbyTagName()

    4. getTagName()

  32. What is the original name of JavaScript?

    1. LiveScript

    2. EScript

    3. Mocha

    4. JavaScript

  33. Which one is Ternary Operator?

    1. ?*

    2. ?:

    3. >?

    4. <?

  34. Javascript is a which type of language 

    1. Interpreted

    2. Compiled

  35. Which of the following function of String object returns the characters in a string between two indexes into the string? 

    1. substr()

    2. substring()

    3. string()

    4. count()

  36. A function definition expression is known as 

    1. Function calls

    2. Function definiation

    3. Function calling

    4. Function literal

  37. The script must placed in 

    1. head

    2. head and body

    3. title and body

    4. all of the mentioned

  38. Which of the following attribute is used to include external js code inside your HTML document?

    1. src

    2. external

    3. script

    4. link

  39. A proper scripting language is a 

    1. High level programming language

    2. Assembly level programming language

    3. Machinen level programming language

    4. Low level programming language

  40. Javascript code can be called by using

    1. RMI

    2. Triggering Event

    3. Preprocessor

    4. Function/Method

  41. The snippet that has used to check if "a" is not equal to "null" is 

    1. if(a!=null)

    2. if(a!)

    3. if(a!null)

    4. if(a!==null)

  42. The property of primary expression is 

    1. stand-alone expressions

    2. basic expressions containing all necessary functions

    3. contains variable references alone

    4. complex expressions

  43. A statement block is a 

    1. conditional block

    2. block that contains a single statement

    3. Both conditional block and single statement

    4. block that combines multiple statements into a single compound statement

  44. When an empty statement encountered, javascript interpreter

    1. Ignores the statement

    2. Prompts to complete the statement

    3. Throws an error

    4. Throws an exception

  45. The "var and "function" are

    1. Declaration statements

    2. Datatypes

    3. Prototypes

  46. What are the three important manipulations done in a for loop on a loop variable?

    1. Updation, Incrementation, Initialization

    2. Initialization,Testing, Updation

    3. Testing, Updation, Testing

    4. Initialization,Testing, Incrementation

  47. Which of the following keywords is used to define a variable in Javascript?

    1. var

    2. fun

    3. Both A and B

    4. None of the above

  48. Which of the following methods can be used to display data in some form using Javascript?

    1. document.write()

    2. console.log()

    3. window.alert()

    4. All of the above

  49. How can a datatype be declared to be a constant type?

    1. var

    2. const

    3. let

    4. constant

  50. What is the purpose of script loading?

    1. Load JavaScript files manually

    2. Load JavaScript files programmatically

    3. Both A and B