JavaScript Questions & Answers – Client-Side JavaScript

«
»

This set of Javascript Multiple Choice Questions & Answers (MCQs) focuses on “Client-Side JavaScript”.

1. The main purpose of JavaScript in web browser is to ___________
a) Creating animations and other visual effects
b) User Interface
c) Visual effects
d) User experience
View Answer

Answer: a
Explanation: JavaScript can help to facilitate that experience, for example by:

  1. Creating animations and other visual effects to subtly guide a user and help with page navigation
  2. Sorting the columns of a table to make it easier for a user to find what she needs
advertisement

2. A JavaScript program can traverse and manipulate document content through __________
a) Element Object
b) Document Object
c) Both Element and Document Object
d) Data object
View Answer

Answer: c
Explanation: A JavaScript program can traverse and manipulate document content through the Document object and the Element objects it contains. It can alter the presentation of that content by scripting CSS styles and classes. The Element object represents an HTML element, like P, DIV, A, TABLE, or any other HTML element.

3. The behaviour of the document elements can be defined by __________
a) Using document object
b) Registering appropriate event handlers
c) Using element object
d) Using data element
View Answer

Answer: b
Explanation: The JavaScript program can define the behavior of document elements by registering appropriate event handlers. A JavaScript program can traverse and manipulate document content through the Document object and the Element objects it contains.
advertisement
advertisement

4. The service(s) that enables networking through scripted HTTP requests is __________
a) XMLHttpResponse
b) XMLRequest
c) XMLHttpRequest
d) XMLHttps
View Answer

Answer: c
Explanation: The best known advanced services is the XMLHttpRequest object, which enables networking through scripted HTTP requests. The XMLHttpRequest object can be used to request data from a web server.

5. The HTML5 specification does not includes __________
a) Data storage
b) Graphics APIs
c) Other APIs for web apps
d) Networking
View Answer

Answer: d
Explanation: The HTML5 specification (which, at the time of this writing, is still in draft form) and related specifications are defining a number of other important APIs for web apps. These include data storage and graphics APIs.The data storage api can store data locally within the user’s browser.
advertisement

6. Which of the following is not an advanced services?
a) Data storage
b) Networking
c) XMLHttpRequest object
d) Graphics APIs
View Answer

Answer: d
Explanation: Data storage is used to store data locally on user’s computer and networking is used for connecting between different platforms.

7. JavaScript code between a pair of “script” tags are called __________
a) Non-inline
b) External
c) Referenced
d) Inline
View Answer

Answer: d
Explanation: The <script> tag is used to define a client-side script (JavaScript). The <script> element either contains scripting statements, or it points to an external script file through the src attribute. Inline code are those that are written between a pair of “script” tags.
advertisement

8. Client-side JavaScript code is embedded within HTML documents in __________
a) A URL that uses the special javascript:encoding
b) A URL that uses the special javascript:stack
c) A URL that uses the special javascript:protocol
d) A URL that uses the special javascript:code
View Answer

Answer: c
Explanation: The Client-side JavaScript code is embedded within HTML documents in four ways :

  1. Inline, between a pair of “script” tags
  2. From an external file specified by the src attribute of a “script” tag
  3. In an HTML event handler attribute, such as onclick or onmouseover
  4. In a URL that uses the special javascript: protocol.

9. What is the programming philosophy that argues that content and behaviour should as much as possible be kept separate?
a) Unobtrusive JavaScript
b) Obtrusive JavaScript
c) Inherited JavaScript
d) Modular JavaScript
View Answer

Answer: a
Explanation: A programming philosophy known as unobtrusive JavaScript argues that content (HTML) and behavior (JavaScript code) should as much as possible be kept separate. According to this programming philosophy, JavaScript is best embedded in HTML documents using “script” elements with src attributes.
advertisement

10. Which of the following communicates with server-side CGI scripts through HTML form submissions and can be written without the use of JavaScript?
a) Static Web Pages
b) Interactive Web Pages
c) Conditional Web Pages
d) All web pages
View Answer

Answer: b
Explanation: An interactive web page can dynamically vary its content based on user preferences. Interactive web pages that communicate with server-side CGI scripts through HTML form submissions were the original “web application” and can be written without the use of JavaScript.

Sanfoundry Global Education & Learning Series – Javascript Programming.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter