Explore topic-wise MCQs in Javascript.

This section includes 145 Mcqs, each offering curated multiple-choice questions to sharpen your Javascript knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the code for getting the current time?

A. ow = new Date();
B. ar now = new Date();
C. ar now = Date();
D. ar now = new Date(current);
Answer» C. ar now = Date();
2.

Client-side JavaScript code is embedded within HTML documents in

A. URL that uses the special javascript:encoding
B. URL that uses the special javascript:stack
C. URL that uses the special javascript:protocol
D. URL that uses the special javascript:code
Answer» D. URL that uses the special javascript:code
3.

JavaScript code between a pair of “script” tags are called

A. on-inline
B. xternal
C. eferenced
D. nline
Answer» E.
4.

The HTML5 specification includes

A. ata storage
B. raphics APIs
C. ther APIs for web apps
D. ll of the mentioned
Answer» E.
5.

The service(s) that enables networking through scripted HTTP requests is

A. MLHttpResponse
B. MLRequest
C. MLHttpRequest
D. ll of the mentioned
Answer» D. ll of the mentioned
6.

The behaviour of the document elements can be defined by

A. sing document object
B. egistering appropriate event handlers
C. sing element object
D. ll of the mentioned
Answer» C. sing element object
7.

Which is the method used for registering handlers?

A. n()
B. egister()
C. dd()
D. nclude()
Answer» B. egister()
8.

Why does Node not block while waiting for operations to complete?

A. tatic
B. synchronous
C. ynchronous
D. one of the mentioned
Answer» C. ynchronous
9.

The necessary globals of a node are defined under which namespace?

A. ariables
B. ystem
C. rocess
D. sing
Answer» D. sing
10.

The new Java arrays can be created into a JavaScript programs using which of the following classes?

A. ava.Array
B. ava.lang.*
C. ava.lang.Array
D. ava.lang.reflect.Array
Answer» E.
11.

The JavaScript classes can be instantiated using _____ operator?

A. reate
B. ew
C. nstantiate
D. reate.new
Answer» C. nstantiate
12.

When the “end” event fires on EOF when no more data will arrive, which function is called?

A. .on("data",f);
B. .on("end",f);
C. .on("error",f);
D. .on("default",f);
Answer» C. .on("error",f);
13.

What is the method used to pause “data” events?

A. .pause();
B. .stop();
C. .halt();
D. .wait();
Answer» B. .stop();
14.

What is the code snippet to change the class and let the stylesheet specify the details?

A. imestamp.className = "highlight";
B. imestamp.className = "change";
C. imestamp.className = "specify";
D. imestamp.className = "move";
Answer» B. imestamp.className = "change";
15.

Which of the following is not an object?

A. lement
B. ocation
C. osition
D. indow
Answer» D. indow
16.

What is the code snippet to update the content of the timestamp element when the user clicks on it?

A. imestamp.onLoad = function() { this.innerHTML = new Date().toString(); }
B. imestamp.onclick = function() { this.innerHTML = new Date().toString(); }
C. imestamp.onload = function() { this.innerHTML = new Date().toString(); }
D. imestamp.onclick = function() { innerHTML = new Date().toString(); }
Answer» C. imestamp.onload = function() { this.innerHTML = new Date().toString(); }
17.

What is the code snippet to find all container elements with class “reveal”?

A. ar elements = document.getElementsByClassName("reveal");
B. ar elements = document.getElementByClassName("reveal");
C. ar elements = document.getElementByName("reveal");
D. ar elements = document.getElementsClassName("reveal");
Answer» B. ar elements = document.getElementByClassName("reveal");
18.

The style property belongs to while of the following object?

A. lement
B. indow
C. ocation
D. one of the mentioned
Answer» B. indow
19.

What are the properties supporting CSS styles for a document element?

A. tyle and font
B. tyle and className
C. ize and style
D. lassName and font
Answer» C. ize and style
20.

What is the function used to deregister event handler ‘f’?

A. eleteAllListeners(name)
B. eleteListener(name,f)
C. emoverListener(name,f)
D. emoveAllListeners(name)
Answer» D. emoveAllListeners(name)
21.

The language is commonly used to

A. pecify the user’s language
B. pecify the language going to be scripted
C. o longer in use
D. pecify the programmer’s favorable language
Answer» D. pecify the programmer’s favorable language
22.

What is the default value of the type attribute?

A. ext/css
B. ext/javascript
C. ext
D. ml
Answer» C. ext
23.

What will be done if more than one page requires a file of JavaScript code?

A. ownloads that many times
B. etrives from the browser cache
C. ust be re executed
D. one of the mentioned
Answer» C. ust be re executed
24.

One of the main advantage of using src attribute is

A. t becomes self-cached
B. t makes the HTML file modular
C. t restricts manipulation in the HTML file
D. t simplifies the HTML files
Answer» E.
25.

What is the lifetime of the data stored through localStorage?

A. Permanent
B. Temporary
C. Both Permanent and Temporary at times
D. Cannot store
Answer» B. Temporary
26.

Which of the following is a web application API framework?

A. Dojo
B. YUI
C. GWT
D. jQuery
Answer» D. jQuery
27.

What does Rhino do when the getter and setter methods exist?

A. It becomes JavaScript properties
B. Java classes are used to avoid them
C. Java classes & JavaScript properties
D. It act as javascript function
Answer» B. Java classes are used to avoid them
28.

The word “document” mainly refers to

A. Dynamic Information
B. Static Information
C. Both Dynamic and Static Information
D. Temporary information
Answer» C. Both Dynamic and Static Information
29.

Which is the function used to store a value?

A. setItem()
B. set()
C. storeItem()
D. store()
Answer» B. set()
30.

What is the purpose of the event handlers in the JavaScript?

A. Adds innerHTML page to the code
B. Performs handling of exceptions and occurrences
C. Allows JavaScript code to alter the behaviour of windows
D. Change the server location
Answer» D. Change the server location
31.

The JavaScript classes can be instantiated using _____ operator.

A. create
B. new
C. instantiate
D. create.new
Answer» C. instantiate
32.

Which is the property that represents the content displayed in the window?

A. document
B. content
C. window
D. frame
Answer» B. content
33.

How to pick a document element based on the value of its id attribute?

A. getElementsbyId()
B. getElementbyId()
C. both getElementsbyId() and getElementbyId()
D. getElement
Answer» C. both getElementsbyId() and getElementbyId()
34.

What is the function used to deregister event handler 'f'?

A. deleteAllListeners(name)
B. deleteListener(name,f)
C. removeListener(name,f)
D. removeAllListeners(name)
Answer» D. removeAllListeners(name)
35.

Which is the Microsoft's own proprietary client-side storage?

A. IE User Data
B. Offline Web Applications
C. Cookies
D. Offline Apis
Answer» B. Offline Web Applications
36.

The new Java arrays can be created into JavaScript programs using which of the following classes?

A. java.Array
B. java.lang.*
C. java.lang.Array
D. java.lang.reflect.Array
Answer» E.
37.

Which is more widely used than GWT in Google?

A. Closure
B. Dojo
C. Procedure
D. jQuery
Answer» B. Dojo
38.

The localStorage and sessionStorage belongs to ___________

A. Window object
B. Element object
C. Hash object
D. DOM object
Answer» B. Element object
39.

Which is the function used to retrieve a value?

A. get()
B. retrieve()
C. getItem()
D. retrieveItem()
Answer» D. retrieveItem()
40.

When will the window property come into play?

A. Representation convenience
B. Use as an extension of other objects
C. Use objects in the Window object
D. Refer to window object itself
Answer» E.
41.

Which of the following object belongs to the style property?

A. Element
B. Window
C. Location
D. Dynamic
Answer» B. Window
42.

Which is more widely used than GWT in Google?%!

A. Closure
B. Dojo
C. Procedure
D. jQuery
Answer» B. Dojo
43.

The new Java arrays can be created into a JavaScript programs using which of the following classes?%!

A. java.Array
B. java.lang.*
C. java.lang.Array
D. java.lang.reflect.Array
Answer» E.
44.

What is the command used for debugging output in Node?%!

A. print();
B. console.log(…);
C. debug(…);
D. execute(…);
Answer» C. debug(‚Äö√Ѭ∂);
45.

Which is the method used for registering handlers?%!

A. on()
B. register()
C. add()
D. include()
Answer» B. register()
46.

The HTML5 specification includes%!

A. Data storage
B. Graphics APIs
C. Other APIs for web apps
D. All of the mentioned
Answer» E.
47.

What will be the return value of the write() method when the Node cannot write the data immediately and has to buffer it internally?%!

A. 0
B. 1
C. True
D. False
Answer» E.
48.

Which Window object method is used to display message in a dialog box?%!

A. alert()
B. prompt()
C. message()
D. none of the mentioned
Answer» B. prompt()
49.

How to pick a document element based on the value of its id attribute?%!

A. getElementsbyId()
B. getElementbyId()
C. both getElementsbyId() and getElementbyId()
D. none of the mentioned
Answer» C. both getElementsbyId() and getElementbyId()
50.

Which handler is triggered when the content of the document in the window is stable and ready for manipulation?%!

A. onload
B. manipulate
C. create
D. none of the mentioned
Answer» B. manipulate