Monday 19 March 2012

MCQ For Javascript


1. Inside which HTML element do we put the JavaScript?Client-side
A)     <javascript>
B)     <scripting>
C)     <script>
D)     <js>

2. What is the correct JavaScript syntax to write "Hello World"?
A) ("Hello World")
B) response.write("Hello World")
C) document.write("Hello World")
D) "Hello World"

3. Where is the correct place to insert a JavaScript?
A) The <head> section
B) The <body> section
C) Both the <head> section and the <body> section are correct
D) None of this

4. What is the correct syntax for referring to an external script called "xxx.js"?
A) <script type="text/javascript" name="xxx.js">
B) <script type="text/javascript" href="xxx.js">
C) <script type="text/javascript" src="xxx.js">

5. The external JavaScript file must contain the <script> tag
A) True
B) False

6. How do you write "Hello World" in an alert box?
A) alert("Hello World")
B) alertBox="Hello World"
C) msgBox("Hello World")
D) alertBox("Hello World")

7. How do you create a function?
A) function:myFunction()
B) function myFunction()
C) function=myFunction()
D) None of this

8. How do you call a function named "myFunction"?
A) call function myFunction
B) call function()
C) call myFunction()
D) myFunction()

9. How do you write a conditional statement for executing some code if "i" is equal to 5?
A) if (i==5)
B) if i==5 then
C) if i=5 then
D) if i=5

10. How do you write a conditional statement for executing some code if "i" is NOT equal to 5?
A) if <>5
B) if =! 5 then
C) if (i != 5)
D) if (i <> 5)

11. How does a "while" loop start?
A) while (i<=10)
B) while (i<=10;i++)
C) while i=1 to 10
D) None of this

12. How does a "for" loop start?
A) for (i <= 5; i++)
B) for (i = 0; i <= 5)
C) for i = 1 to 5
D) for (i = 0; i <= 5; i++)

13. How can you add a comment in a JavaScript?
A) <!--This is a comment-->
B) 'This is a comment
C) //This is a comment
D) All of above

14. What is the correct JavaScript syntax to insert a comment that has more than one line?
A) /*This comment has
more than one line*/
B) <!--This comment has
more than one line-->
C) //This comment has
more than one line//
D) None of this

15. What is the correct way to write a JavaScript array?
A) var txt = new Array(1:"tim",2:"kim",3:"jim")
B) var txt = new Array:1=("tim")2=("kim")3=("jim")
C) var txt = new Array("tim","kim","jim")
D) var txt = new Array="tim","kim","jim"

16. How do you round the number 7.25, to the nearest integer?
A) rnd(7.25)
B) Math.round(7.25)
C) Math.rnd(7.25)
D) round(7.25)

17. How do you find the number with the highest value of x and y?
A) Math.max(x,y)
B) ceil(x,y)
C) Math.ceil(x,y)
D) top(x,y)

18. How can you find a client's browser name?
A) browser.name
B) client.navName
C) navigator.appName
D) client.appName

19 . ______ 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

20. What should appear at the very end of your JavaScript?
The <script LANGUAGE="JavaScript">tag
A) The </script>
B) The <script>
C) The END statement
D) None of the above

21. Which of the following is not a valid JavaScript variable name?
A) _first_and_last_names
B) 2names
C) FirstAndLast
D) None of the above

22. Which of the following attribute can hold the JavaScript version?
A) LANGUAGE
B) SCRIPT
C) VERSION
D) None of the above

23. 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>

24. Which of the following navigator object properties is the same in both   Netscape and IE?
A) navigator.appName
B) navigator.appCodeName
C) navigator.appVersion
D) None of the above

25. Which of the following best describes JavaScript?
A) a low-level programming language.
B) a scripting language precompiled in the browser.
C) a compiled scripting language.
D) an object-oriented scripting language.

26. ______method evaluates a string of JavaScript code in the context of the specified object.
A) Eval
B) ParseInt
C) ParseFloat
D) Efloat

27. 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

28. JavaScript is interpreted by _________
A) Client
B) Server
C) Object
D) None of the above

29. Using _______ statement is how you test for a specific condition.
A) Select
B) If        
C) Switch
D) For

30). Which of the following is the structure of an if statement?
A) if (conditional expression is true) thenexecute this codeend if
B) if (conditional expression is true)execute this codeend if
C) if (conditional expression is true)   {then execute this code>->}
D) if (conditional expression is true) then {execute this code}

31. The _______ method of an Array object adds and/or removes elements from an array.
A) Reverse
B) Shif
C) Slice
D) Splice

32. Which tag(s) can handle mouse events in Netscape?
A) <IMG>
B) <BR>
C) <A>
D) All of the above

33. The syntax of close method for document object is ______________
A) Close(doc)
B) Close(object)
C) Close(val)
D) Close()

Answer

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


Posted By : Hemangi Zala

No comments:

Post a Comment