About JavaScript

Following are some of the multiple choice questions on the JavaScript with answers that will help the students in developing their knowledge.

JavaScript MCQ

1. In javascript what is a block of statement

  • block that combines multiple statements into a single compound statement
  • both conditional block and single statement
  • block that contains a single statement
  • conditional block

2. Which one of the following also known as conditional expression in javascript

  • Alternative to if-else
  • Switch statement
  • If-then-else statement
  • immediate if

3. Is this correct syntax to include JS Code inside HTML Page ?<script type="text/javascript">...</script>

  • Yes
  • No

4. File extension for external JS files

  • .javascript
  • .js
  • .jscript
  • .script

5. Which type of javascript language is ___

  • Object-Oriented
  • Object-Based
  • Assembly-language
  • High-level

6. How would you access the second element in an array?

  • nums.2
  • nums[2]
  • nums_1
  • nums[1]

7. When does the function name become optional in javascript

  • When the function is defined as a looping statement
  • When the function is defined as expressions
  • When the function is predefined
  • None of these

8. What is the correct javascript syntax to change the content of the html element below?

  • document.getElement("p").innerHTML = "Hello World!"
  • document.getElementById("demo").innerHTML = "Hello World!";
  • document.getElementByName("p").innerHTML = "Hello World!";
  • demo.innerHTML = "Hello World!";

9. In asps, the code to tie the database to the web site is typically written in javascript or ____.

  • VBScript
  • Visual Basic
  • Both A & B
  • None of these

10. The main purpose of javascript in web browser is to

  • Creating animations and other visual effects
  • User Interface
  • Visual effects
  • All of above

11. Which of the following is the correct syntax to redirect a url using JavaScript?

  • document.location='http://www.newlocation.com';
  • browser.location='http://www.newlocation.com';
  • navigator.location='http://www.newlocation.com';
  • window.location='http://www.newlocation.com';

12. Use the ________ element to associate javascript with a web page.

  • object
  • script
  • embed
  • canvas

13. We cannot Place JS Code in the body tag . Say true/false.

  • True
  • False.

14. Which of the following function of String object returns the index within the calling String object of the first occurrence of the specified value?

  • substr()
  • search()
  • lastIndexOf()
  • indexOf()

15. The ____ object allows you to change to a new web page from within javascript code.

  • Location
  • clearInterval()
  • Both A & B
  • None of these

16. Which of the following operator is used for the Assignment Operator?

  • ==
  • !
  • =
  • +

17. Which of the following is NOT a valid component of a function declaration?

  • Function keyword
  • Function name
  • Pair of Square Braces
  • Pair of Curly Braces

18. Window.googlejavascriptredirect=1var n={navigateto:function(b,a,d){if(b!=a&&b.google){if(b.google.r

19. The external javascript file must contain the tag.

  • True
  • False

20. This saves a value, which can be then assigned when writing code

  • Parameter
  • Function
  • Variable
  • none of the above

21. Indicates the beginning and the end of a JavaScript section.

  • <html> </html>
  • <style> </style>
  • <article> </article>
  • <script> </script>

22. Is JavaScript case sensitive language?

  • Yes
  • No
  • Depends on the browser
  • Depends on the platform

23. What will be the output of the following javascript code

  • False
  • Ture

24. JavaScript is designed for following purpose -

  • To Style HTML Pages
  • To Perform Server Side Scripting Opertion
  • To add interactivity to HTML Pages.
  • To Execute Query Related to DB on Server

25. Assignment Operators is following type of operator ______________.

  • Binary
  • Unary
  • Ternary
  • None of these

26. Inside which HTML element do we put the JavaScript?

  • <js>
  • <script>
  • <scripting>
  • <javascript>

27. Which of the following is NOT a valid starting character for JS variable names?

  • Uppercase Letter
  • Lowercase Letter
  • Dollar Sign
  • Underscore

28. ______ tag is an extension to HTML that can enclose any number of JavaScript statements.

  • <SCRIPT>
  • <BODY>
  • <HEAD>
  • <TITLE>

29. Var num;Above Statement is called as __________ Statement.

  • Instantization
  • Globalization
  • Declaration
  • Initialization

30. What is the correct JavaScript syntax to write "Hello World"?

  • System.out.println("Hello World")
  • println ("Hello World")
  • document.write("Hello World")
  • response.write("Hello World")

31. Which of the following is not a feature of javascript?

  • Lightweight
  • Good for the applications which are network-centric
  • Object oriented
  • Open source

32. State the correct place of JS Code inside HTML -

  • Inside Body
  • Inside Head
  • Inside Single JavaScript File
  • All of these

33. Symbol pair used to code backspace within string value

  • \b
  • \bspace
  • \backspace
  • \n

34. What property tells you how many items are in an array?

  • items
  • count
  • length
  • num

35. Which of these lines of code show how to validly store an array with 3 items?

  • var nums = [42, 3, 7];
  • var nums = 3, 42, 7;
  • var nums = [3];
  • var nums = (3, 42, 7);

36. Conditional Operator shown in the following example is _____________.

  • Unary Operator
  • Ternary Operator
  • Binary Operator
  • None of these

37. Guess the ternary operator used in the following example !!!

  • Colon Operator
  • Conditional Operator
  • Bitwise Operator
  • Logical Operator

38. JavaScript contains a _________________ that assigns a value to a variable based on some condition.

  • Conditional operator
  • Logical Operator
  • Assignment operator
  • Bitwise Operator

39. Adding String and Integer always results in _________.

  • Character
  • String
  • Integer
  • None of these

40. What will be the output of the following script ?

  • 5
  • true
  • 1
  • false

41. "Add and Assignment" operator is shown by this symbol.

  • +==
  • +=
  • ==+
  • =+

42. "===" operator is _______________.

  • Is equal to
  • Is identical (is equal to and is of the same type)
  • Is identical (is equal to and is of the different type)
  • None of these

43. "+=" operator can operate on following data values.

  • Float
  • String
  • Integer
  • All Options

44. Which of the following is not an logical operator ?

  • &&
  • ||
  • !
  • |

45. Which of the following operator is used to concatenate two strings.

  • Dot
  • Arrow
  • Comma
  • Plus

46. "++" is __________ type of operator.

  • Ternary
  • Binary
  • Unary
  • All of above

47. What type of value gets printed if we add following two variables ?var a = "1";var b = 5;

  • Integer
  • Long
  • Number
  • Text

48. Integer Variable + Character Variable + Undefined Variable = ______________ Value

  • Undefined Value
  • Integer
  • Character
  • None of these

49. "++" can operate only on ________________.

  • Constants
  • Variables
  • Text
  • None of these

50. Non Initialized Variable have value "undefine", What value be printed in following case -var carname="Volvo";var carname;

  • undefined
  • Error
  • Volvo
  • None of these

Enjoyed the Quiz. Share this with friends

Comments

Add Your Review

Your email address will not be published.

Subscribe to Newsletter!

Subscribe to get latest updates and information.