COP FINAL
11. Where in an HTML document are functions called?
a. <a></a> b. <body></body> c. <head></head> d. All of the above
37. What type of JavaScript array is displayed below using key/value pairs? var states = new Array(); states["CA"] = "90210"; states["ME"] = "01234"; states["MT"] = "55641"; states["FL"] = "32829";
associative array
16. Given var result = eval("100 / 5 - 4"); what would result's value be?
b. 16
18. What type of dialog box is this in JavaScript? Do you really want to exit?
b. confirm();
33. When developing JavaScript programs the developer must set the <script> tag element's language attribute to __________.
c. "javascript"
36. What is the primary difference between ++x and x++?
c. ++x is pre-increment, x++ is post-increment
22. Including comments in HTML and JavaScript is good programming practice. An example of block comment in HTML is __________.
d. <!-- This is an block comment -->
18. When using anonymous functions in JavaScript arguments cannot be passed to the function.
false
14. &&, ||, and ! are called what in JavaScript?
logical operators
33. True/False: In HTML DOM everything is a node.
true
19. The HTML tag element creates a table row in a table?
<tr>
What does var date = new Date();, return when printed
Day of the week, date, time
22. When a function is defined in JavaScript the expected received data values are called?
parameters
30. Which of the following is a valid block comment in JavaScript?
a. /* This is a block comment */
12. A common use for using nested loops is to display data in a table format using rows and columns.
true
<img>
Image
21. JavaScript programs are executed by a JavaScript ¬¬_________ in a Web browser.
Interpreter
UNIX start date is defined as starting on
January 1, 1970 00:00:00
3. Which of the following is not part of the three layers of a Web page?
Java
30. In JavaScript computer programs can execute a sequence of statements, branch to an alternative sequence of statements based on evaluating a condition, and repeat a sequence of statements based on evaluating a condition. What is this called?
a. Conditional expressions b. Control structures c. Looping constructs d. All of the above
var date = new Date(14, 9, 22)
Thu Oct 22 1914 00:00:00 <some time zone depending upon the computer>
20. When passing data to a function in JavaScript which of the following statements is true?
a. Data values passed to a function are called arguments b. Data values passed to a function are enclosed in parentheses c. Multiple data values passed to a function are separated using a comma d. All of the above
15. The comparison operator = = = is used to determine what?
a. If two operands are identical in value and type
15. Which of the following is true about a nested loop?
a. Is a loop within a loop
24. Core objects in JavaScript include which of the following?
a. Math b. Date c. Strings d. All of the above
16. Operands can be of data type __________.
a. String b. Numeric c. Boolean
26. Two commonly used validation tools are __________ and __________.
a. W3C Validation Tool b. Validome Validation Tool
25. When does an HTML document become a document object?
a. When it is loaded into a web browser
2. Which of the following is a valid data type of that a variable can hold?
a. boolean c. string d. numeric
10. The variable named data is initialized as follows: var data = "Data data data"; and is reused later in the JavaScript program. Which of the following is a valid reuse of the variable data?
a. data = 43; b. data = true; c. data = null;
27. Given var data = "45.12"; how would data be explicitly converted to a float?
a. data = parseFloat(data);
20. What type of dialog box is this in JavaScript? Enter a Number
a. prompt();
32. When naming variables in JavaScript, which of the following would be valid?
a. var message; b. var _9; d. var five5s;
28. Including comments in HTML and JavaScript is good programming practice. An example of an inline comment in JavaScript is __________.
b. // This is an inline comment
35. String comparison in computer science evaluates the data alphabetically based on the __________ which is based on the _________ value of the letter.
b. ASCII, numeric
4. JavaScript can __________.
b. Improve website usability.
31. When using functions parseInt("Route 66"); and parseFloat("Route 66.5"), what order is the data evaluated to convert to an integer and floating point number respectively?
b. Left to right
24. Anonymous functions in JavaScript are unique because its definition is assigned to a __________ since they don't have a __________.
b. Variable, name
37. The three types of dialog boxes inherit to JavaScript for user interaction include confirm();, prompt();, and __________.
b. alert();
document.getElementById("theWord").innerHTML = word; 30. Which part of the statement returns the element with the id attribute of the specified value?
b. getElementById("theWord")
36. When using Math.random(), if values greater than 0-1 are desired what should be programmed? a. Multiply the function by some value b. Add some value to the function c. A and B d. none of the above
c. A and B
6. Website lifecycle is a request/response loop. A request is made when __________.
c. A user types in www.ucf.edu in the URL text box of a Web browser and hits the enter key
9. Composite data types, also known as complex types, consist of more than one component. Valid composite data types include all of the following except __________.
undefined
17. Once declared, functions in JavaScript can be used how many times?
unlimited
21. Variable scope in JavaScript defines where the variable is __________in the program or where it can be used.
visible
22. UNIX start time in computer science is called __________.
epoch
1. JavaScript is the same as Java and as HTML
false
21. True/False: When using the Math object in JavaScript an instance of the object MUST be created using the keyword new before any properties or methods can be used.
false
6. The keyword return can be used anywhere in a <script></script> tag element.
false
True/False: When using functions from the Math object you must declare an instance of the Math object, for example var mathClass = new Math();.
false
var age = 62; if(age >= 65) document.write("You can retire!"); else document.write("Sorry, you have to keep working like a dog."); 39. Based on the code example above what would the conditional if(age >= 65) evaluate as?
false
23. JavaScript is a __________ programming language.
loosely typed
3. The following JavaScript code is an example of what type of loop? <script> var asterisk = "*"; for (var row = 0; row < 10; row++) { for (var column = 0; column < row; column++) { document.writeln(asterisk); } document.writeln("<br>"); } </script>
nested loop
function setLetter(word, letter, display) { if( word == null ) { return; } else { while( word.search( letter ) != -1 ) { var index = word.search( letter ); display = display.substr( 0, index ) + letter + display.substr( index + 1 ); word = word.substr( 0, index ) + '-' + word.substr( index + 1 ); } // Update the display document.getElementById("theDashes").innerHTML = display; } } 15. var index = word.search( letter ); uses which String object method?
search
11. Well-formed statements written in JavaScript end with __________.
semicolon ;
document.getElementById("theWord").innerHTML = word; 32. Which part of the statement is explicitly setting the text associated with the specified element to some value?
=word [[Think of when you have x + y = z, you are setting x + y to z.]]
three ways to create an array in JavaScript?
a. Condensed b. Literal c. Regular
26. One second is equals how many milliseconds?
1000 milliseconds
25. When developing JavaScript programs the developer must set the <script> tag element's type attribute to __________.
"text/javascript"
13. What operator is used for concatenation?
+
When using Math.random() function of the Math object random numbers returned are between
0 (inclusive) and 1 (exclusive)
function getWord() { var words = new Array("JAVASCRIPT", "COMPUTER", "PROGRAMMING", "OPERATOR", "OPERAND", "CONDITIONAL", "REPETITION", "FUNCTION", "ARRAY", "ERROR", "LOOP", "BOOLEAN", "STRING"); var index = Math.floor( Math.random() * words.length ); return words[index]; } 17. What are the potential values of variable index based on the Math object function calls var index = Math.floor( Math.random() * words.length );?
0-12
28. What would the result of Math.floor(12.5) be?
12
17. Given the expression var sum = 19 + 83; which parts of the expression are operands?
19 and 83
Based on the String declaration var word = "COP 2500 Concepts in Computer Science";, what would the result of word.length be
37
<div>
A division or section in an HTML document
29. Given <p id="course">COP 2500<p/>, what is the innerHTML when using document.getElementById("course").innerHTML?
COP 2500
When creating a Date Object in JavaScript using var myDate = new Date();, Date() is called
Constructor
5. Variables declared outside of functions that can be used or changed anywhere in the program are called __________.
Global variables
7. JavaScript is used to enhance ________ Web pages for an interactive experience.
HTML
What is the output of the HTML tag element <hr/>
Horizontal line
<br/>
Line break
Date/time measured in
Milliseconds
function getWord() { var words = new Array("JAVASCRIPT", "COMPUTER", "PROGRAMMING", "OPERATOR", "OPERAND", "CONDITIONAL", "REPETITION", "FUNCTION", "ARRAY", "ERROR", "LOOP", "BOOLEAN", "STRING"); var index = Math.floor( Math.random() * words.length ); return words[index]; } 18. If the value of variable index equals 6, which element of array words would be returned by function getWord()?
REPETITION
function setLetter(word, letter, display) { if( word == null ) { return; } else { while( word.search( letter ) != -1 ) { var index = word.search( letter ); display = display.substr( 0, index ) + letter + display.substr( index + 1 ); word = word.substr( 0, index ) + '-' + word.substr( index + 1 ); } // Update the display document.getElementById("theDashes").innerHTML = display; } } 13. document.getElementById("theDashes").innerHTML in the above code references what?
c. An HTML element with the id attribute set to theDashes
1. A closure function includes what
c. An anonymous function within the function definition
20. There are two attributes of the Date object that start at 0 rather than 1, just to mess with us mere humans , which attributes illogically start at 0 even though day of the month starts at 1?
c. Month and Day of the Week
38. JavaScript is a client-side language because it works __________.
c. On the local computer
34. Precedence in JavaScript determines how the __________ binds to its __________.
c. Operator, operands
19. What would the output be in the alert dialog box based on the following JavaScript code? var num1 = "8675"; var num2 = "309"; var result = num1 + num2; alert("Result is " + result);
c. String result is 8675309
27. Assuming good HTML form and embedded <script></script>, when using concatenation what output would display based on the statement: document.write("The weather is " + 54 + " degrees and raining");
c. The weather is 54 degrees and raining
31. To declare a constant, a value that cannot be changed during programming execution requires the use of keyword __________.
c. const
25. Given var data = "10"; how would data be explicitly converted to the primitive data type Boolean?
c. data = Boolean(data);
32. The ternary operator mimics which conditional in JavaScript?
c. if/else
7. Recursion is a function that __________.
calls itself
38. The array declaration statement var weekdays = new Array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday"); is an example of creating an array using the __________ format.
condensed
34. When laying out data in an HTML document in a table format, to create rows and columns which tag elements must be used? a. <table> b. <tr> c. <td> d. All of the above
d. All of the above
8. After a function has been declared in the <head></head> section of the HTML document, how many times can it be used in the <body></body>?
d. As many times as required
13. When calling a declared function setLetter(word, letter, display) how many arguments must be passed for the function to compile?
d. None are required to compile or run
function setLetter(word, letter, display) { if( word == null ) { return; } else { while( word.search( letter ) != -1 ) { var index = word.search( letter ); display = display.substr( 0, index ) + letter + display.substr( index + 1 ); word = word.substr( 0, index ) + '-' + word.substr( index + 1 ); } // Update the display document.getElementById("theDashes").innerHTML = display; } } 16. When calling declared function setLetter(word, letter, display) how many arguments must be passed for the function to compile?
d. None are required to compile or run
14. Local variables are declared inside of JavaScript functions and can be used or modified __________.
d. Only in the function they are declared
12. The JavaScript logical not operator (!) results in the __________.
d. Reverse evaluation of the condition
29. Primitive data types are assigned __________.
d. Single literal values
8. When asked to develop unobtrusive JavaScript this means that the JavaScript is __________.
d. Stored in an external file with a .js file extension
29. Given var data = "76.45"; how would data be explicitly converted to an integer?
d. data = parseInt(data);
28. Which of the following is a valid looping constructs in JavaScript?
do/while
document.getElementById("theWord").innerHTML = word; 31. Which part of the statement gets the text associated with the specified element?
innerHTML Why? Because the innerHTML is the property that is the text associated with the id.
19. Given the following code example, what are rowLoop and columnLoop called in JavaScript? rowLoop: for (var row = 0; row < 10; row++) { columnLoop: for (var column = 0; column < row; column++) { document.writeln("*"); if(column == 7) break rowLoop; } }
labels
function setLetter(word, letter, display) { if( word == null ) { return; } else { while( word.search( letter ) != -1 ) { var index = word.search( letter ); display = display.substr( 0, index ) + letter + display.substr( index + 1 ); word = word.substr( 0, index ) + '-' + word.substr( index + 1 ); } // Update the display document.getElementById("theDashes").innerHTML = display; } } 14. word = word.substr( 0, index ) + '-' + word.substr( index + 1 ); uses which String object method?
substring
26. Which of the following is a valid decision-making construct in JavaScript?
switch
10. Functions must be declared before they can be used
true
2. The following call to a JavaScript function is valid. <form> <input type="button" value="Welcome" onClick="greetings('Students');"/> </form>
true
23. JavaScript allows for any data type to be assigned to a variable.
true
23. True/False: The Math object in JavaScript allows for performing mathematical tasks.
true
24. HTML Web page files are saved using file extension .htm or .html.
true
27. True/False: The Math object has built in properties, such as Math.PI, and 19 built in methods.
true
35. True/False: HTML tag element <input> is an HTML button.
true
4. A JavaScript function can be called using the HTML anchor tag element, for example <a href="JavaScript:greetings()">Click here</a>
true
5. Numeric literals can be integers (whole numbers) and floating point (fractional numbers with a decimal point).
true
9. In JavaScript, based on the function definition in the <head> and the function call in the <body>, is the function call valid? <head><script> function mileage(inMiles, inGas) { var miles = parseInt(inMiles); var gas = parseInt(inGas); return miles/gas; } </script></head> <body> <script> var gasMileage = mileage(200, 5, 4); alert("Gas mileage is " + gasMileage + " miles to the gallon"); </script> </body>
yes