Olete.in
Articles
Mock Tests
🧪 JavaScript MCQ Quiz Hub
JavaScript MCQ Questions And Answers
Choose a topic to test your knowledge and improve your JavaScript skills
1. Why so JavaScript and Java have similar name?
JavaScript is a stripped-down version of Java
JavaScript's syntax is loosely based on Java's
They both originated on the island of Java
None of the above
2. When a user views a page containing a JavaScript program, which machine actually executes the script?
The User's machine running a Web browser
The Web server
A central machine deep within Netscape's corporate offices
None of the above
3. _____ JavaScript is also called client-side JavaScript.
Microsoft
Navigator
LiveWire
Native
4. _______ JavaScript is also called server-side JavaScript.
Microsoft
Navigator
LiveWire
Native
5. What are variables used for in JavaScript Programs?
Storing numbers, dates, or other values
Varying randomly
Causing high-school algebra flashbacks
None of the above
6. __ JavaScript statements embedded in an HTML page can respond to user events such as mouse-clicks, form input, and page navigation.
Client-side
Server-side
Local
Native
7. What should appear at the very end of your JavaScript? The <script LANGUAGE="JavaScript">tag
The &lt;/script&gt;
The &lt;script&gt;
The END statement
None of the above
8. Which of the following can't be done with client-side JavaScript?
Validating a form
Sending a form&#039;s contents by email
Storing the form&#039;s contents to a database file on the server
None of the above
9. Which of the following are capabilities of functions in JavaScript?
Return a value
Accept parameters and Return a value
Accept parameters
None of the above
10. Which of the following is not a valid JavaScript variable name?
2names
_first_and_last_names
FirstAndLast
None of the above
11. _____ tag is an extension to HTML that can enclose any number of JavaScript statements.
&lt;SCRIPT&gt;
&lt;BODY&gt;
&lt;HEAD&gt;
&lt;TITLE&gt;
12. How does JavaScript store dates in a date object?
The number of milliseconds since January 1st, 1970
The number of days since January 1st, 1900
The number of seconds since Netscape&#039;s public stock offering.
None of the above
13. Which of the following attribute can hold the JavaScript version?
LANGUAGE
SCRIPT
VERSION
None of the above
14. What is the correct JavaScript syntax to write "Hello World"?
System.out.println(&quot;Hello World&quot;)
println (&quot;Hello World&quot;)
document.write(&quot;Hello World&quot;)
response.write(&quot;Hello World&quot;)
15. Which of the following way can be used to indicate the LANGUAGE attribute?
&lt;LANGUAGE=&quot;JavaScriptVersion&quot;&gt;
&lt;SCRIPT LANGUAGE=&quot;JavaScriptVersion&quot;&gt;
&lt;SCRIPT LANGUAGE=&quot;JavaScriptVersion&quot;&gt; JavaScript statements…&lt;/SCRIPT&gt;
&lt;SCRIPT LANGUAGE=&quot;JavaScriptVersion&quot;!&gt; JavaScript statements…&lt;/SCRIPT&gt;
16. Inside which HTML element do we put the JavaScript?
&lt;js&gt;
&lt;scripting&gt;
&lt;script&gt;
&lt;javascript&gt;
17. What is the correct syntax for referring to an external script called " abc.js"?
&lt;script href=&quot; abc.js&quot;&gt;
&lt;script name=&quot; abc.js&quot;&gt;
&lt;script src=&quot; abc.js&quot;&gt;
None of the above
18. Which types of image maps can be used with JavaScript?
Server-side image maps
Client-side image maps
Server-side image maps and Client-side image maps
None of the above
19. Which of the following navigator object properties is the same in both Netscape and IE?
navigator.appCodeName
navigator.appName
navigator.appVersion
None of the above
20. Which is the correct way to write a JavaScript array?
var txt = new Array(1:&quot;tim&quot;,2:&quot;kim&quot;,3:&quot;jim&quot;)
var txt = new Array:1=(&quot;tim&quot;)2=(&quot;kim&quot;)3=(&quot;jim&quot;)
var txt = new Array(&quot;tim&quot;,&quot;kim&quot;,&quot;jim&quot;)
var txt = new Array=&quot;tim&quot;,&quot;kim&quot;,&quot;jim&quot;
21. What does the <noscript> tag do?
Enclose text to be displayed by non-JavaScript browsers.
Prevents scripts on the page from executing.
Describes certain low-budget movies.
None of the above
22. If para1 is the DOM object for a paragraph, what is the correct syntax to change the text within the paragraph?
New Text?
para1.value=&quot;New Text&quot;;
para1.firstChild.nodeValue= &quot;New Text&quot;;
para1.nodeValue=&quot;New Text&quot;;
23. JavaScript entities start with _______ and end with _________.
Semicolon, colon
Semicolon, Ampersand
Ampersand, colon
Ampersand, semicolon
24. Which of the following best describes JavaScript?
a low-level programming language.
a scripting language precompiled in the browser.
. a compiled scripting language.
an object-oriented scripting language.
25. Choose the server-side JavaScript object?
FileUpLoad
Function
File
Date
26. Choose the client-side JavaScript object?
Database
Cursor
Client
FileUpLoad
27. Which of the following is not considered a JavaScript operator?
New Text?
this
delete
typeof
28. _____method evaluates a string of JavaScript code in the context of the specified object.
Eval
ParseInt
ParseFloat
Efloat
29. Which of the following event fires when the form element loses the focus: <button>, <input>, <label>, <select>, <textarea>?
onfocus
onblur
onclick
ondblclick
30. The syntax of Eval is _______________
[objectName.]eval(numeriC.
[objectName.]eval(string)
[EvalName.]eval(string)
[EvalName.]eval(numeriC.
31. JavaScript is interpreted by ________
Client
Server
Object
None of the above
32. Using _______ statement is how you test for a specific condition.
Select
If
Switch
For
33. Which of the following is the structure of an if statement?
if (conditional expression is true) thenexecute this codeend if
if (conditional expression is true)execute this codeend if
if (conditional expression is true) {then execute this code&gt;-&gt;}
if (conditional expression is true) then {execute this code}
34. How to create a Date object in JavaScript?
dateObjectName = new Date([parameters])
dateObjectName.new Date([parameters])
dateObjectName := new Date([parameters])
dateObjectName Date([parameters])
35. The _______ method of an Array object adds and/or removes elements from an array.
Reverse
Shift
Slice
Splice
36. To set up the window to capture all Click events, we use which of the following statement?
window.captureEvents(Event.CLICK);
window.handleEvents (Event.CLICK);
window.routeEvents(Event.CLICK );
window.raiseEvents(Event.CLICK );
37. Which tag(s) can handle mouse events in Netscape?
&lt;IMG&gt;
&lt;A&gt;
&lt;BR&gt;
None of the above
38. ___________ is the tainted property of a window object.
Pathname
Protocol
Defaultstatus
Host
39. To enable data tainting, the end user sets the _________ environment variable.
ENABLE_TAINT
MS_ENABLE_TAINT
NS_ENABLE_TAINT
ENABLE_TAINT_NS
40. In JavaScript, _________ is an object of the target language data type that encloses an object of the source language.
a wrapper
a link
a cursor
a form
41. When a JavaScript object is sent to Java, the runtime engine creates a Java wrapper of type ___________
ScriptObject
JSObject
JavaObject
Jobject
42. _____ class provides an interface for invoking JavaScript methods and examining JavaScript properties.
ScriptObject
JSObject
JavaObject
Jobject
43. _______ is a wrapped Java array, accessed from within JavaScript code.
JavaArray
JavaClass
JavaObject
JavaPackage
44. A ________ object is a reference to one of the classes in a Java package, such as netscape.javascript .
JavaArray
JavaClass
JavaObject
JavaPackage
45. The JavaScript exception is available to the Java code as an instance of __________
netscape.javascript.JSObject
netscape.javascript.JSException
netscape.plugin.JSException
None of the above
46. To automatically open the console when a JavaScript error occurs which of the following is added to prefs.js?
user_pref(&quot; javascript.console.open_on_error&quot;, false);
user_pref(&quot;javascript.console.open_error &quot;, true);
user_pref(&quot;javascript.console.open_error &quot;, false);
user_pref(&quot;javascript.console.open_on_error&quot;, true);
47. To open a dialog box each time an error occurs, which of the following is added to prefs.js?
user_pref(&quot;javascript.classic.error_alerts&quot;, true);
user_pref(&quot;javascript.classic.error_alerts &quot;, false);
user_pref(&quot;javascript.console.open_on_error &quot;, true);
user_pref(&quot;javascript.console.open_on_error &quot;, false);
48. The syntax of a blur method in a button object is ______________
Blur()
Blur(contrast)
Blur(value)
Blur(depth)
49. The syntax of capture events method for document object is ______________
captureEvents()
captureEvents(args eventType)
captureEvents(eventType)
captureEvents(eventVal)
50. The syntax of close method for document object is _____________
Close(doC.
Close(object)
Close(val)
Close()
Submit