Question: QUESTION 1 With the Date object, getTime() returns the number of milliseconds since January 1, 1970 True False 2 points QUESTION 2 Using magic numbers
QUESTION 1
"With the Date object, getTime() returns the number of milliseconds since January 1, 1970"
True
False
2 points
QUESTION 2
Using magic numbers in your code is a good practice.
True
False
2 points
QUESTION 3
The highest index in an array ____.
| is the same as the length of the array | ||
| is one more than the length of the array | ||
| is one less than the length of the array | ||
| is set at 100 by Google |
2 points
QUESTION 4
Ponder the select element. How would you assign the value property selected by the user to the variable x? (select1.gif)
| x = document.getElementById('pies').value; | ||
| x = document.getElementById('f1').value; | ||
| x = document.f1.pies.value; | ||
| x = document.getElementById['pies'][2]; |
2 points
QUESTION 5
Properties or methods added to the ____ object become available to all instances of this object's children.
| prototype | ||
| archetype | ||
| maker | ||
| penultimate |
2 points
QUESTION 6
A(n) ____ statement is used to exit control statements.
| else | ||
| continue | ||
| break | ||
| default |
2 points
QUESTION 7
The ____ method adds one or more elements to the end of an array.
| pop() | ||
| push() | ||
| shift() | ||
| unshift() |
2 points
QUESTION 8
"When you declare an array like the following, you _____. var cars = ["focus", "yaris", "mini"];"
| are creating an array using a constructor function | ||
| are declaring an array using literal notation. | ||
| Incorrect |
2 points
QUESTION 9
Which two instructions create a new array and assignes it to the variable n? Choose 2 answers.
| Array[n]; | ||
| Array(n); | ||
| var n = new Array(); | ||
| var n = []; |
2 points
QUESTION 10
What does the variable m hold after these lines execute?
var x = ["red", "orange", "yellow"", "green", "blue"]; m = x.splice(2, 2);
| ["red","yellow"] | ||
| ["yellow","green"] | ||
| ["red", "orange"] | ||
| "["orange","yellow"] |
2 points
QUESTION 11
_____ is the name for the process of converting data into a format that can be stored or transmitted across a network and later recovered into the same format as the original.
| Serialization | ||
| Normalization | ||
| Denaturization | ||
| Sequentation |
2 points
QUESTION 12
This code is an example of ____.
if(document.getElementById) { x = document.getElementById("box").value; } else { x = document.form1.box1.value; }
| browser sniffing | ||
| browser detection | ||
| feature detection | ||
| magic number insertion |
2 points
QUESTION 13
"Unlike the while statement, the statements in a _____ statement always execute at least once, before a conditional expression is evaluated."
| do...continue | ||
| do...using | ||
| do...until | ||
| do...while |
2 points
QUESTION 14
The splice() method _____. Choose 2 answers
| allows removing elements from an array | ||
| allows adding elements to an array | ||
| joins two strings together | ||
| allows removing part of a string |
2 points
QUESTION 15
Advantages of OOP are ____. Choose 3 answers.
| code reuse | ||
| encapsulation | ||
| inheritance | ||
| automatic refactoring |
2 points
QUESTION 16
Consider the code below. How do you read Joe's age into the variable y?
var people = [ {name: "stu", age: 23, height: 72}, {name: "sue", age: 29, height: 72}, {name: "joe", age: 33, height: 72}, {name: "moe", age: 42, height: 72} ];
| y = joe.age; | ||
| y = people.joe; | ||
| y = people[3].age; | ||
| y = people[2].age; |
2 points
QUESTION 17
What will the variable x hold after the loop finishes? var x = 1; for(var i = 0; i
| 11 | ||
| 9 | ||
| 8 | ||
| none of the above |
2 points
QUESTION 18
You cannot assign a JavaScript function to a variable.
True
False
2 points
QUESTION 19
"Consider the code below. How do your read the value of the width into a variable named w?"
var rect = {length: 9, width: 6};
| w = width | ||
| w = rect[0] | ||
| w = rect.width | ||
| w = rect[1] |
2 points
QUESTION 20
What is y after this executes? x = 3.14159; y = Math.floor(x)
| 4 | ||
| 3.2 | ||
| 3 | ||
| 3.1416 |
2 points
QUESTION 21
How many times will this loop execute?
x = 0; sum = 0; while(x
| 0 | ||
| 3 | ||
| 4 | ||
| infinity |
2 points
QUESTION 22
You run this code in March 2014. what is m?
d = new Date(); m = d.getMonth();
| 3 | ||
| Mar | ||
| 2 | ||
| March |
2 points
QUESTION 23
What is displayed by the alert box?
var names = new Array(41, 22, 64, 98, 16, 22); var index = 4; alert(names[index]);
| 22 | ||
| 41 | ||
| 98 | ||
| None of the above |
2 points
QUESTION 24
Here 23 is called?
for(i = 0; i
| a magic number | ||
| a prototype | ||
| Incorrect |
2 points
QUESTION 25
The ____ method removes and returns the first element from the beginning of an array.
| split() | ||
| unshift() | ||
| shift() | ||
| slice() |
2 points
QUESTION 26
The array join() method _____
| converts an array of values into a string | ||
| breaks a string into an array of elements | ||
| joins two arrays together to make a larger array | ||
| joins two string together to make a larger string |
2 points
QUESTION 27
In creating a data structure like this _____.
var rect = new Object(); rect.height = 9;
| you have created a direct instance of an object | ||
| you have created an object using a custom constructor function | ||
| you have created an object literal | ||
| you have created an array literal |
2 points
QUESTION 28
Math.random() produces a number ____.
| from 0.0 up to but not including 1.0 | ||
| from 0.0 up to and including 1.0 | ||
| Incorrect |
2 points
QUESTION 29
You have this form. Assume any necessary HTML is present. what happens if you click the 3rd radio button then click the ""click Me"" button? (radios1.gif)
| nothing happens | ||
| the alert displays "sausage"" | ||
| The alert displays "schrooms"" | ||
| the alert displays "S" |
2 points
QUESTION 30
An array is a useful JavaScript data structure.
True
False
2 points
QUESTION 31
How many times will this loop execute?
var x = 0; for(var i = 5; i > 12; i++) { x = x + 2; }
| 7 | ||
| 6 | ||
| 8 | ||
| 0 |
2 points
QUESTION 32
In the array shown, the number 4 will be stored at index ____.
var temps = [1, 2, 4, 8, 16, 32];
| 0 | ||
| 1 | ||
| 2 | ||
| 3 |
2 points
QUESTION 33
How would you assign 'Wilma' to the variable n?
var names = new Array(); names[0] = ['Jose', 'Jones']; names[1] = ['Wilma', 'Flintstone'];
| n = names[0][0]; | ||
| n = names[1][0]; | ||
| n = names[0][1]; | ||
| n = names[1][1]; |
2 points
QUESTION 34
A for-loop is sometimes called a counting loop
True
False
2 points
QUESTION 35
When you've created a data structure like this ____.
var rect = {length: 9, width: 6};
| you have created a direct instance of an object | ||
| you have created an object using a custom constructor function | ||
| you have created an object literal | ||
| you have created an array literal |
2 points
QUESTION 36
A ____ statement restarts a loop with a new iteration.
| break | ||
| continue | ||
| next | ||
| default |
2 points
QUESTION 37
What does this code produce?
var num = Math.random(); var d = num * 10 + 1; d = Math.floor(d);
| a random whole number betwen 0 and 10 | ||
| a random whole number betwen 1 and 9 | ||
| a random whole number betwen 1 and 11 | ||
| a random whole number betwen 1 and 10 |
2 points
QUESTION 38
"Once a web page has finished loading, then the ____ event handler fires."
| loaded | ||
| onload | ||
| complete | ||
| done |
2 points
QUESTION 39
"When this runs what is the value of p?
function Pizza(toppings, diameter) { this.numOfToppings = toppings; this.size = diameter; this.calcPrice = function() { var c = this.numOfToppings + this.size; return c; }; } var pie1 = new Pizza(2, 10); var pie2 = new Pizza(3, 12); var p = pie2.calcPrice();"
| 12 | ||
| 13 | ||
| 14 | ||
| 15 |
2 points
QUESTION 40
After this code runs, what is the length of this array?
var x = new Array(); x[0] = 5; x[1] = 9; x[5] = 2;
| 0 | ||
| 2 | ||
| 6 | ||
| 4 |
2 points
QUESTION 41
The following line calls the function named foo every 700 milliseconds. How do you make it stop?
t1 = setInterval("foo", 700);
| it stops by itself after running once | ||
| call clearTimeout(t1); | ||
| call clearTimeout(); | ||
| call clearTimeout('foo') |
2 points
QUESTION 42
Given this object, how would you assign the model to a variable named m?
var myCar = {make: "Plymouth", model: "Valiant", year: 1968}
| myCar.model(m); | ||
| m = myCar.model; | ||
| m = model.model; | ||
| m = model.myCar; |
2 points
QUESTION 43
What is the value of x after these lines execute?
var names = new Array("Smith", "Jones", "Thomas", "Wilson", "Green"); var x = names.length;
| 3 | ||
| 4 | ||
| 5 | ||
| 6 |
2 points
QUESTION 44
Each repetition of a looping statement is called a(n) ____.
| tag | ||
| point | ||
| renewn | ||
| iteration |
2 points
QUESTION 45
When the following line runs an alert pops up saying "hello".
var m = function(){ alert("hello"); };
True
False
2 points
QUESTION 46
What does the variable m hold after these lines execute?
var x = ["red", "orange", "yellow", "green", "blue"]; m = x.slice(1, 4);
| [ "orange", "yellow", "green", "blue"] | ||
| ["red", "orange", "yellow", "green"] | ||
| ["red", "orange", "yellow" ] | ||
| ["orange", "yellow", "green"] |
2 points
QUESTION 47
Your program has a button with an id = "b2". what does this code do?
document.getElementById("b2").onclick = function(){ alert("Yo!"); };
| assigns an anonymous function to the onclick event of the button. | ||
| assigns a function named "alert" to the onclick event of the button. | ||
| when the button is clicked a message box with "alert" pops up. |
2 points
QUESTION 48
After the for-loop ends the value of the variable nameFound will be false. Why?
var names = ["Smith", "Jones", "Thomas", "Wilson", "Green"]; for(i=0; i
| because Thomas is not spelled correctly | ||
| it is a law that all names must be lower case | ||
| the if-block test uses only 1 equal sign | ||
| nameFound will be true the 3rd time through the loop, but will be overwritten as false for the 4th and 5th times. |
2 points
QUESTION 49
What happens after this code runs?
r = ['red', 'rojo', 'ruby']; r.push('rouge');
| 'rouge' is added to the beginning of the array at index 0 | ||
| r will hold 'rouge' only, the other elements will be erased | ||
| 'rouge' is added to the end of the array at index 3 | ||
| 'rouge' is added to the end of array at index 4 |
2 points
QUESTION 50
If you intend to create many identical object instances it is best to use an object constructor function you write to create the objects
True
False
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
