JAVASCRIPT Exam Questions and Answers Latest Graded A+, Exams of Javascript programming

JAVASCRIPT Exam Questions and Answers Latest Graded A+

Typology: Exams

2025/2026

Available from 05/18/2026

DrBenard
DrBenard 🇺🇸

3.5K documents

1 / 16

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
JAVASCRIPT Exam Questions and Answers Latest Graded A+
1. Inside which HTML element do we put the JavaScript?
<scripting>
<script>
<js>
<javascript> - ✔✔<script>
2. What is the correct JavaScript syntax to change the content of the HTML element below?
<p id="demo">This is a demonstration.</p>
document.getElement("p").innerHTML = "Hello World!";
#demo.innerHTML = "Hello World!";
document.getElementByName("p").innerHTML = "Hello World!";
document.getElementById("demo").innerHTML = "Hello World!"; -
✔✔document.getElementById("demo").innerHTML = "Hello World!";
3. Where is the correct place to insert a JavaScript?
The <body> section
Both the <head> section and the <body> section are correct
The <head> section - ✔✔Both the <head> section and the <body> section are correct
4. What is the correct syntax for referring to an external script called "xxx.js"?
<script name="xxx.js">
<script src="xxx.js">
<script href="xxx.js"> - ✔✔<script src="xxx.js">
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download JAVASCRIPT Exam Questions and Answers Latest Graded A+ and more Exams Javascript programming in PDF only on Docsity!

JAVASCRIPT Exam Questions and Answers Latest Graded A+

  1. Inside which HTML element do we put the JavaScript?
  1. The external JavaScript file must contain the /This comment has more than one line/ //This comment has more than one line//
  • ✔✔/This comment has more than one line/
  1. What is the correct way to write a JavaScript array? var colors = (1:"red", 2:"green", 3:"blue") var colors = "red", "green", "blue" var colors = ["red", "green", "blue"] var colors = 1 = ("red"), 2 = ("green"), 3 = ("blue") - ✔✔var colors = ["red", "green", "blue"]
  2. How do you round the number 7.25, to the nearest integer? rnd(7.25) Math.rnd(7.25) Math.round(7.25) round(7.25) - ✔✔Math.round(7.25)
  3. How do you find the number with the highest value of x and y? ceil(x, y) Math.max(x, y) Math.ceil(x, y) top(x, y) - ✔✔Math.max(x, y)
  1. What is the correct JavaScript syntax for opening a new window called "w2"? w2 = window.open("http://www.w3schools.com"); w2 = window.new("http://www.w3schools.com"); - ✔✔w2 = window.open("http://www.w3schools.com");
  2. JavaScript is the same as Java. True False - ✔✔False
  3. How can you detect the client's browser name? client.navName navigator.appName browser.name - ✔✔navigator.appName
  4. Which event occurs when the user clicks on an HTML element? onclick onmouseover onmouseclick onchange - ✔✔onclick
  5. How do you declare a JavaScript variable? var carName; v carName; variable carName; - ✔✔var carName;
  1. Which sign does jQuery use as a shortcut for jQuery? the % sign the? Sign the $ sign - ✔✔the $ sign
  2. Look at the following selector: $("div"). What does it select? All div elements The first div element - ✔✔All div elements
  3. Is jQuery a library for client scripting or server scripting? Client scripting Server scripting - ✔✔Client scripting
  4. Is it possible to use jQuery together with AJAX? No Yes - ✔✔Yes
  5. The jQuery html() method works for both HTML and XML documents True False - ✔✔False
  6. What is the correct jQuery code to set the background color of all p elements to red? $("p").style("background-color","red");

$("p").layout("background-color","red"); $("p").manipulate("background-color","red"); $("p").css("background-color","red"); - ✔✔$("p").css("background-color","red");

  1. With jQuery, look at the following selector: $("div.intro"). What does it select? All div elements with class="intro" The first div element with id="intro" All div elements with id="intro" The first div element with class="intro" - ✔✔All div elements with class="intro"
  2. Which jQuery method is used to hide selected elements? hidden() hide() display(none) visible(false) - ✔✔hide()
  3. Which jQuery method is used to set one or more style properties for selected elements? html() css() style() - ✔✔css()
  4. Which jQuery method is used to perform an asynchronous HTTP request? jQuery.ajaxSetup() jQuery.ajaxAsync() jQuery.ajax() - ✔✔jQuery.ajax()

nameConflict() noNameConflict() conflict() noConflict() - ✔✔noConflict()

  1. Which jQuery method is used to switch between adding/removing one or more classes (for CSS) from selected elements? switch() switchClass() altClass() toggleClass() - ✔✔toggleClass()
  2. Look at the following selector: $("div p"). What does it select? The first p element inside a div element All p elements inside a div element All div elements with a p element - ✔✔All p elements inside a div element
  3. Is jQuery a W3C standard? No Yes - ✔✔No
  4. Look at the following selector: $("p#intro"). What does it select? The p element with id="intro" All p elements with class="intro" - ✔✔The p element with id="intro"
  5. Which jQuery method is used to remove selected elements?

Both methods can be used remove() detach() - ✔✔Both methods can be used

  1. Look at the following selector: $(":disabled"). What does it select? All disabled input elements All hidden elements All elements containing the text "disabled" All elements that does not contain the text "disabled" - ✔✔All disabled input elements
  2. Which jQuery method returns the direct parent element of the selected element? parent() ancestors() parents() ancestor() - ✔✔parent()
  3. The jQuery animate() method can be used to animate ANY CSS property? All properties except the shorthand properties Yes Only properties containing numeric values - ✔✔Only properties containing numeric values Which statement about the space parameter in JSON.stringify() is false? Select one: a. It controls spacing in the resulting JSON string b. It is an optional parameter

a. / or { b. " or c. ; or : d. < or > - ✔✔b. " or What is the value of json in the following code? var obj = { fruit: apple', toJSON: function () { returnorange'; } }; var json = JSON.stringify({x: obj}); Select one: a. {"x":"orange"} b. {"fruit":"orange"} c. {"x":"apple"} d. {"fruit":"apple"} - ✔✔a. {"x":"orange"} Which statement about the replacer parameter in JSON.stringify() is true? Select one: a. If null or omitted, all properties of the object are included in the resulting JSON string b. If an array, specifies the names of the properties in the object to include in the resulting JSON string c. If a function, transforms values and properties encountered while stringifying d. All three statements are true - ✔✔d. All three statements are true Can you use a double quote inside a JSON string? Select one: a. No, you should use single quotes b. Yes, if you use the ascii code. c. Yes, if it is escaped like ( " ) d. Yes, you can use it without any special treatment - ✔✔c. Yes, if it is escaped like ( " ) What is a JSONStringer used for? Select one: a. It is used to create number strings in JSON.

b. It is used to quickly create JSON text. c. It is used to create JSON ordered pairs. d. It quickly converts JSON to Java strings. - ✔✔b. It is used to quickly create JSON text. What function will convert a JavaScript object to a JSON string? Select one: a. JSON.text() b. JSON.toString() c. JSON.serialize() d. JSON.stringify() - ✔✔d. JSON.stringify() Which of these is a benefit JSON has over XML? Select one: a. JSON is more forgiving of poor formatting b. JSON has less markup requirements and therefore is lighter than XML c. JSON does not need to be stored in a file to be sent remotely d. JSON can be written poorly and still be parsed - ✔✔b. JSON has less markup requirements and therefore is lighter than XML What is the value of json in the following code? var cars = []; cars[0] = Ford'; cars[1] =Toyota'; cars[2] = BMW'; var json = JSON.stringify({x: cars}); Select one: a. {"x":{"Ford","Toyota","BMW"}} b. {"cars":["Ford","Toyota","BMW"]} c. {"x":["Ford","Toyota","BMW"]} d. {"x":[Ford','Toyota','BMW']} - ✔✔c. {"x":["Ford","Toyota","BMW"]} True or false? A disadvantage of JSON is that it requires the use of JavaScript. Select one: a. True, though JavaScript is readily available in today's browsers.

d. Strings, Arrays, Primitives and Objects - ✔✔d. Strings, Arrays, Primitives and Objects In what situation would you want to use XML over JSON? Select one: a. When JSON is not offered. b. You need message validation or you're using XSLT. c. Never, JSON is worlds better. d. When you need to use tags to structure your content. - ✔✔b. You need message validation or you're using XSLT. What kind of format is JSON, and what does the acronym mean? Select one: a. A lightweight data-interchange format. JavaScript Object Notation. b. A lightweight database framework. JavaScript Object Notation. c. A lightweight data-interchange format. Java Objective Notion. d. A lightweight data-encoding framework. Java Omnipresent Notation. - ✔✔a. A lightweight data- interchange format. JavaScript Object Notation.