JavaScript Set 2 (40 mcqs)

1. The JavaScript file inside the ________ tag in ________ section of HTML document.
A.</script>,</head>
B.<script>,<head>
C.<script>,<title>
D.<script>,<body>

2. Which of the following is true?
A.If onKeyDown returns false, the key-press event
B.If onKeyPress returns false, the key-down event
C.If onKeyDown returns false, the key-up event is
D.If onKeyPress returns false, the key-up event is

3. _____ JavaScript statements embedded in an HTML page can respond to user events such as mouse-clicks, form input, and page navigation. | Java Script
A.Client-side
B.Server-side
C.Local
D.Native

4. Which event can be generated when the user clicks a reset button?
A.onreset
B.onresetbtn
C.onresbt
D.None of the above

5. Which event can be generated when a drag-and-drop operation is undertaken?
A.ondrop
B.ondrag
C.ondragdrop
D.None of the above

6. The basic syntax of the event handlers is:
A.name_of_handler=”JavaScript code here”
B.”JavaScript code here”=name_of_handler
C.name_of_handler==”JavaScript code here”
D.None of the above

7. Which is the correct syntax of javascript?
A.function writestatus(){ status=”Do not click he
B.function writestatus(){ status=”Do not click h
C.function writestatus(){ status=”Do not click he
D.function writestatus(){ status=”Do not click h

8. Executing a JavaScript function –
A.before the page has loaded
B.after the page has loaded
C.before the page has unloaded
D.after the page has unloaded

9. Which event can be generated when the user clicks on an element?
A.onclk event
B.onaction event
C.onclick event
D.after the page has unloaded

10. Which is the correct statement?
A.mousedown, user depresses the mouse button on th
B.mouseup, user releases the mouse button on this
C.click, one mousedown and one mouseup detected on
D.All of the above

11. ________refers to the element the mouse comes from.
A.toElement
B.fromElement
C.noElement
D.anyElement

12. Which event can be generated when data changes in a control,such as a text field?
A.onchange
B.onchg
C.onchan
D.None of the above

13. Which event can be generated when the mouse leaves an element?
A.onmouseout
B.onmousedown
C.onmousemove
D.onmouseover
14. A _________ in javascript can contain multiple parameters of different data types.
A.function
B.same function
C.another function
D.inner function

15. The lifetime of the parameters begin
A.when the function is invoked
B.when the execution of the function is over
C.when the function is declined
D.None of the above

16. How to assign a function to a variable with the javascript Function constructor?
A.var f=Function(“x”,”y”,”return x+y”);
B.var f=Function(x,y){return x+y;}
C.var f=new Function(“x”,”y”,”return x + y”);
D.None of the above

17. A function in javascript takes
A.parameters
B.operates on them
C.returns the required result
D.All of the above

18. A _________ refers to a function embedded within a function.
A.nested function
B.same function
C.another function
D.inner function

19. A callback is a function to be executed
A.after same function is executed.
B.after another function is executed.
C.after within another function is executed.
D.None of the above

20. When the body of a page is loaded,you can no longer use the ________
A.document.write method
B.document.read method
C.document.put method
D.document.get method

21. When return a value from a function with the ________
A.ret
B.return Statement
C.retn
D.None of the above

22. State whether the following statements are True or False. i) JavaScript ignores spaces, tabs and newlines that appear in JavaScript program. ii) Semicolons are necessary while writing JavaScript statements. iii) JavaScript is a case-sensitive language.
A.i- True, ii- False, iii-True
B.i- False, ii- True, iii-True
C.i-True, ii-True, iii-False
D.i- False, ii- False, iii-True

23. In JavaScript, a ___________ is simply an identifier followed by a colon that is applied to a statement or block of code.
A.bookmark
B.label
C.break
D.continue
24. A JavaScript function which can be defined dynamically along with the new operator using ________
A.Nested Function
B.Function Literals
C.Function ( ) Constructor
D.None of the above

25. A function literal is an expression that defines unnamed function. The syntax for function literal is ________
A.var variable name=function (Argument list){Funct
B.variable name=function (Argument list){Function
C.var variable name =new function(Arg1, Arg2, ….
D.variable name =new function(Arg1, Arg2, ……,”

26. Match the following JavaScript function with their description. i) onblur a) script runs when element changes ii) onmouseup b) script runs when the form is reset iii) onchange c) script runs when the element lost focus. iv) onreset d) script runs when mouse button is released.
A.i-d, ii-c, iii-a, iv-b
B.i-b, ii-c, iii-a, iv-d
C.i-c, ii-d, iii-a, iv-b
D.i-a, ii-c, iii-d, iv-b

27. Which of the following are the advantages of JavaScript? i) Less server interaction ii) Immediate feedback to visitors iii) Reading or writing of files iv) Increased interactivity
A.i, ii and iii only
B.i, iii and iv only
C.i, ii and iv only
D.All i, ii, iii, and iv

28. What is the output of following JavaScript? < script type=”text/javascript”> function x() { document.write(2+5+”8″); } < /script >
A.258
B.Error
C.7
D.78

29. What does isNaN function do in JavaScript?
A.Return true if the argument is not a number.
B.Return false if the argument is not a number.
C.Return true if the argument is a number.
D.None of the above

30. What is the output of following JavaScript code? < script type=”text/javascript”> function sum(x) { function add(y) { return x+y; } return add; } function callme() { result=sum(5)(5); alert(result); } </script> if you call the function callme(),what will happen?
A.10
B.Error in calling function
C.5
D.None of the above

31. What does isNaN function do in JavaScript?
A.Return true if the argument is not a number.
B.Return false if the argument is not a number.
C.Return true if the argument is a number.
D.None of the above

32. Which is the correct syntax?
A.<script language=”javascript”> function di
B.<srcipt language=”javascript”> function d
C.<script language=’javascript’> function d
D.<script lang =’javascript’> function dis

33. Which is the correct syntax?
A.function mult(operand1,operand2) { return; ope
B.function mult(operand1,operand2) { return oper
C.function mult(operand1,operand2) { return () o
D.function mult(operand1,operand2) { return oper

34. For simple cookies, which field is typically omitted?
A.name
B.expiration date
C.pathname of the web page writing the cookie
D.value

35. The cookie string is actually written to:
A.a hard drive on the server
B.the surfer’s hard drive
C.both A and B
D.neither A nor B

36. Which statement can be used to examine the value of the cookie string associated with the current web page?
A.alert(cookie)
B.alert(document.cookie.value)
C.alert(this.cookie)
D.alert(document.cookie)

37. Given a Date object named expDate that is set to the current date and time, which of the following will change the date value to one week from now?
A.expDate = setWeek(1)
B.expDate.setTime(expDate.getTime() + 30*24*3600*1
C.expDate.setTime(expDate.getTime() + 7*24*60*60)
D.expDate.setTime(expDate.getTime() + 7*24*3600*10

38. Which of the following creates a cookie named userName and stores the value Rahul in it?
A.document.cookie = “userName=Rahul”
B.document.cookie(“userName”, “Rahul”)
C.document.cookie.name = “userName”, document.cook
D.cookiename = “userName”, cookievalue = “Rahul”

39. Which of the following JavaScript cannot do?
A.JavaScript can manipulate HTML elements.
B.JavaScript can be use to validate data.
C.JavaScript can create cookies.
D.All of the above are correct.

40. While reading Cookies, the _________string will keep a list of name = value pairs separated by semicolons, where name is the name of a cookie and value is its string value.
A.document.cookie
B.read.cookie
C.cookie.string
D.name.cookie

Answers

1.B 2.A 3.A 4.A 5.C 6.A
7.A 8.B 9.C 10.D 11.B 12.A
13.A 14.A 15.A 16.C 17.D 18.A
19.B 20.A 21.B 22.A 23.B 24.C
25.A 26.C 27.C 28.D 29.A 30.A
31.A 32.A 33.D 34.C 35.B 36.D
37.D 38.A 39.D 40.A

Sharing is caring!

Leave a Comment

Your email address will not be published. Required fields are marked *

shares