CSCI 1250 Test 3
To output text to a browser window using javaScript, the text must be in: Question options: - [ ] - { } - < > - " "
" "
The logical and operator in JavaScript. Question options: - || - && - ; - <>
&&
What is the final value of answer given the values below for num: if (num < 100) if (num <= 70 && num >= 60) { answer = 'x'; } else answer = 'y'; else answer = 'z'; num is 100, what is answer? Question options: - x - y - z - undefined
...
What is the final value of answer? var answer = 0, choice = "espresso"; if (choice == "ESPRESSO") answer = 1; else answer = 2; Question options: - 0 - 1 - 2 - undefined
...
Which of the following javaScript statements accurately calculates price given the tax_rate and subtotal? Question options: - var price, subtotal; var tax_rate = 0.06; price = subtotal + subtotal * tax_rate; - var price, subtotal; var tax_rate = 0.06; price = subtotal + tax; - var price, subtotal; var tax_rate = 0.06; subtotal * tax_rate; - var price, subtotal; var tax_rate = 0.06; subtotal = price * tax_rate;
...
Which of the following javaScript statements accurately calculates price given the tax_rate and subtotal? Question options: - var price, subtotal; var tax_rate = 0.06; price = subtotal + subtotal * tax_rate; - var price, subtotal; var tax_rate = 0.06; price = subtotal + tax; - var price, subtotal; var tax_rate = 0.06; subtotal * tax_rate; - var price, subtotal; var tax_rate = 0.06; subtotal = price * tax_rate;
...
What is the final value of price given the values below for order: var price = 0.0; if (order == "Big Mac") price = 3.0; else if (order == "Quarter Pounder" ) price = 2.50; Given order is "Whopper" what is price? Question options: - 0.0 - 1.50 - 2.50 - 3.0
0.0
Given that z = 3 and y = 2, what is the resulting value of x? x = (z + 2) - y * 2; Question options: - 0 - 1 - 2 - 5
1
What is the final value of total? var total = 0, priceA = 4, priceB = 5; total = priceA + priceB * 3; Question options: - 0 - 9 - 19 - 18
19
In JavaScript, 17%5 is: Question options: - the name of a variable - 2 - the same as 17/5 - 3
2 17%5 is 2. 2 is the remainder.
Given that x = 3 and y = 1, what is the resulting value of z? z = (6/x + x) - y*2; Question options: - 0 - 1 - 3 - 5
3
What is the final value of price given the values below for order: var price = 0.0; if (order == "Big Mac") price = 3.0; else if (order == "Quarter Pounder" ) price = 2.50; Given order is "Big Mac" what is price? Question options: - 0.0 - 1.50 - 2.50 - 3.0
3.0
The relational operator that tests "less than": Question options: - < - ++ - || - ==
<
JavaScript is added between: Question options: - <java></java> tags - <code></code> tags - <style></style> tags - <script></script> tags
<script></script> tags
The assignment statement which assigns a value to a variable must contain the __________ symbol: Question options: - = - == - ? - @
=
The relational operator that tests "is equal to": Question options: - <= - ++ - || - ==
==
If the following javascript were in an html file, what would happen? <script> alert("HI"); </script> Question options: - An alert box would pop up when the page loads - 'HI' would be the title of the page - "HI" would be displayed when a button is clicked - An alert message would appear in the browser title bar
An alert box would pop up when the page loads
Mouse clicking a button on a web page is known as: Question options: - a handler. - an expression. - an event. - an invalid action.
An event
A JavaScript variable cannot be initialized in the same statement in which it is declared. Question options: - True - False
False
Only one statement can be placed in a <then-statement> or an <else-statement>. Question options: - True - False
False
The parameter list of a function must include at least one parameter. Question options: - True - False
False
The statement terminator in JavaScript is the colon (:). Question options: 1) True 2) False
False
The statement terminator in JavaScript is the colon (:). Question options: 1) True 2) False
False
There is only one valid algorithm to solve a problem. Question options: - True - False
False
What is the final value of greeting when time is 15? if (time < 10) greeting = "Good morning"; else if (time < 20) greeting = "Good day"; else greeting = "Good evening"; Question options: - Good morning - Good day - Good evening - ""
Good day
What is the final value of greeting when time is 2? if (time < 10) greeting = "Good morning"; else if (time < 20) greeting = "Good day"; else greeting = "Good evening"; Question options: - Good morning - Good day - Good evening - ""
Good morning
Given a = 2, b = 3 and c = 5, what is output? if (a == 2 && c >=10) alert("Blue"); else alert("Green"); Question options: - Blue - Green - undefined - 2
Green
Given a = 2, b = 3 and c = 5, what is output? if (a == 2 && c >=10) document.write("Blue"); else document.write("Green"); Question options: - Blue - Green - undefined - nothing
Green
Given the function definition: function myFunction(stringA, stringB) { document.write("I am " +stringA " the " +stringB); } What is output by the following statements: var title = "Superman"; var name = "Clark"; myFunction(title, name); Question options: - I am Clark the Superman - I am Superman the Clark - I am stringA the stringB - I am +stringA the +stringB
I am Clark the Superman
What is output by the following statements? var a=10, b=5, c=0; c = a/2; if (b == c) { alert("Line 1"); } else { alert("Line 2"); } Question options: - Line 1 Line 2 - Line 2 - Line 1 - undefined
Line 1
What is output by the following statements? var a=10, b=5, c=0; c = a/2; if (b == c) document.write("Line 1"); else document.write("Line 2"); document.write("Line 3"); Question options: - Line 1 Line 2 - Line 2 Line 3 - Line 1 Line 3 - undefined
Line 1 Line 3
Having JavaScript in a function allows it to run: Question options: - when the page loads - when the window is refreshed - when the function is called - at the end of the page
When the function is called
What is output by the following: var a = 10; if (a <= 10 && a > 0) { document.write("abc"); document.write("def"); } else { document.write("ghi"); document.write("jkl"); } document.write("mno"); Question options: - abc - abcdef - ghi - abcdefmno
abcdefmno
In javascript, the + has dual roles. The roles are: Question options: - addition and subtraction - addition and multiplication - addition and string concatenation - addition and remission
addition and string concatenation
In JavaScript, output displayed in a popup box can be produced using the: Question options: - alert command - lprint command - printout command - all of the above
alert command
In JavaScript, output displayed in a popup box can be produced using the: Question options: - alert command - lprint command - printout command - all of the above
alert command Alert is used to display output on the screen.
Property of an algorithm: Question options: - Definitenes - Effectiveness - Finiteness - all of the above
all of the above
javaScript detects the following event(s): Question options: - page load - input entered in a text box - button click - all of the above
all of the above
When a button is clicked: Question options: - an onclick event is generated - the function closes - the function is erased - a pop up box is generated
an onclick event is generated
Given i = 90, what is the output of the following? if (i < 90) alert("alpha"); else alert("beta"); Question options: - alpha - beta - alphabeta - no output
beta
Strings in javascript are delimited by: Question options: - ' ' (single quotes) - " " (double quotes) - [ ] - both ' ' (single quotes) and " " (double quotes)
both ' ' (single quotes) and " " (double quotes)
In javascript, output can be produced using: Question options: - alert function - document.write function - declaration statement - both a and b
both a and b
The process of creating software: Question options: - processing - multitasking - debugging - computer programming
computer programming
What does the javaScript Number() method do? Question options: - creates an ordered list - sorts numbers - converts the input to a number - multiplies a number
converts the input to a number
This javascript statement accomplishes what two things? var tax_rate = 0.06; Question options: - declares tax_rate and sets its value to 0.06 - compares tax_rate to the value 0.06 - increments the tax_rate by 0.06 - resets tax_rate to 6
declares tax_rate and sets its value to 0.06
This javascript statement accomplishes what two things? var tax_rate = 0.06; Question options: - declares tax_rate and sets its value to 0.06 - compares tax_rate to the value 0.06 - increments the tax_rate by 0.06 - resets tax_rate to 6
declares tax_rate and sets its value to 0.06
A function is declared by writing its function ________. Question options: - call - invocation - definition - organization
definition
Which javaScript gets the element in the document with id="example": Question options: - querySelector("example"); - element.querySelector(); - example.querySelector(); - document.querySelector("#example");
document.querySelector("#example");
Given the select menu: <select id="topping"> <option value="choc">Chocolate<option> <option value="straw">Strawberry</option> <option value="cara">Caramel</option> </select> Which refences the selection element? Question options: - document.querySelector("topping"); - select.chocolate - topping - document-topping
document.querySelector("topping");
Javascript statement to write to the browser window: Question options: - document.write - print - printf - output
document.write
Output directly onto a Web page from JavaScript is done using: Question options: - writeln( ) - document.write() - print( ) - document.display()
document.write()
All of the following are parts of a function except: Question options: - the name - parameters - global variables - the definition
global variables
count++ is shorthand for: Question options: - add count to count - increment count by 1 - increment count by 2 - initialize count to 1
increment count by 1
In JavaScript, an empty string: Question options: 1) contains a single space enclosed in double quotes 2) is not valid 3) is the same as an undefined value 4) is written as ""
is written as ""
A programming language used to make web pages interactive: Question options: - algorithm - javascript - java - cobol
javascript
The language that allows us to write programs that interact with HTML, and related technologies: Question options: - java - javascript - C - C++
javascript
Which of the following is not a suitable assignment statement? Question options: 1) wages = hours * rate 2) length * width = area 3) class = "College Algebra" 4) score = 92.8
length * width = area
In javaScript, functions linked to events are called: Question options: - linkers - listeners - routines - trackers
listeners
Variables declared inside a function are ________ in scope. Question options: - global - local - virtual - random
local
The three basic data types in javascript are: Question options: - numbers, strings, Booleans - numbers, letters, special characters - input, output, storage - input, data, number
numbers, strings, Booleans
The inputs to a function are called: Question options: - identifiers - parameters - values - algorithms
parameters
All of the following are input elements except: Question options: - text boxes - print - buttons - prompt function
Algorithms that are written in a specific programming language: Question options: - processes - steps - recipes - programs
programs
_____ allows us to get input that is referenced with an id. Question options: - GetID - querySelector - queryID - myID
querySelector
To embed javascript in a web page it must be between ________ tags. Question options: - source - style - script - h1
script
The first step in solving a programming expression is to process: Question options: 1) the part of the expression inside the parentheses 2) multiplication and division 3) addition and subtraction 4) the statement on the left
the part of the expression inside the parentheses
Which of the following is NOT a valid variable name in javascript? Question options: - totalPrice - total price - total_price - TotalPrice
total price
The javaScript to obtain what the user selected from a drop down menu with id="myCar": Question options: - var car = document.querySelector("myCar").value; - myCar = document.querySelector; - var car = select#myCar; - document.querySelector("myCar") = car;
var car = document.querySelector("myCar").value;
Logical names given to locations in memory: Question options: - docs - variables - terms - options
variables
What is the final value of answer given the values below for num: if (num < 100) if (num <= 70 && num >= 60) { answer = 'x'; } else answer = 'y'; else answer = 'z'; num is 60, what is answer? Question options: - x - y - z - undefined
x
To group statements together to create a compound statement, use: Question options: - " " - { } - [ ] - < >
{ }
The logical or operator in JavaScript. Question options: - || - && - ; - <>
||
The value produced by the <expression> in JavaScript's return statement is called the function's value or result. Question options: - True - False
True
When the <Boolean expression> of an if/else statement is false, the <else-statement> of the expression is executed. Question options: 1) True 2) False
True
A Boolean value can be either true or false. Question options: 1) True 2) False
True
A recipe can be an algorithm. Question options: - True - False
True
All variables in a JavaScript program must be declared. Question options: 1) True 2) False
True
In JavaScript, strings must be enclosed by single (') or double (") quotes. Question options: 1) True 2) False
True
JavaScript is an event-based programming language. Question options: - True - False
True
The flow of an assignment statement is always right to left. Question options: 1) True 2) False
True
The name of a function identifies it and must be used when the function is called. Question options: - True - False
True
The number of parameters in a function must match the number of arguments sent to it by the function call. Question options: - True - False
True
The outcome of a relational expression is always true or false. Question options: 1) True 2) False
True
The outcome of a relational expression is true or false. Question options: - True - False
True