Shared Flashcard Set

Details

Intro to Client-Side Web Programming (n341)
Midterm Exam
95
Computer Science
Undergraduate 1
10/13/2015

Additional Computer Science Flashcards

 


 

Cards

Term
A script is a series of instructions that a computer can follow to achieve a goal. (True / False)
(From page 14 of the text)
Definition
True
Term
Scripts are made up of ______ instructions.
(From page 15 of the text)
Definition
step-by-step
Term
A browser uses different parts of the script - depending on how the user interacts with the web page. (True / False)
(From page 15 of the text)
Definition
True
Term
When developing a script, the programmer should typically follow what iterative process?
(From page 17 of the text)
Definition
Step 1- Define the goal.
Step 2- Design the script.
Step 3- Code each step.
Term
When learning a new computer language, it is important to learn both the vocabulary (words that the computer will understand) and the syntax (how to put the words together). (True / False)
(From page 20 of the text)
Definition
True
Term
Computers use data to create simplified models of objects in the human world. (True / False)
(From page 26 of the text)
Definition
True
Term
Match each definition:

Property:
Event:
Method:

(From page 28-32 of the text)
Definition
Property: characteristic of an object
Event: Important thing that happens to an object
Method: task performed by or to an object
Term
The browser sees a web page as an object that contains other objects. The page's URL or the page's title would be an example of ________.
(From page 39 of the text)
Definition
A property
Term
"write()" adds new content to the web page. This is an example of ________.
(From page 39 of the text)
Definition
A method
Term
The Document Object Model (DOM) is a tree-like structure that the browser constructs when rendering a web page. (True / False)
(From page 41 of the text)
Definition
True
Term
Match the web programming layer with the language used for each:

Structure or content of the page:
Style or presentation of the page:
Interactivity or behavior of the page:

(From page 44 of the text)
Definition
HTML
CSS
JavaScript
Term
Which of the following files are written as plain text?

HTML
CSS
JavaScript

(From page 46 of the text)
Definition
All of the above
Term
The following html code: " " a) converts the text to cursive b) links to a JavaScript file from an html page c) enhances the presentation of the web page (From page 49 of the text)
Definition
b) links to a JavaScript file from an html page
Term
For separation of layers, which is the preferred method for using JavaScript with your html page?

-Include it inside the html file b/w opening and closing " < s.c.r.i.p.t > " tags.
-Link to an external file.
(From page 49 of the text)
Definition
Link to an external file.
Term
When JavaScript is used to change the appearance of a web page, the original html file is also changed. (True / False)
(From page 49 of the text)
Definition
False
Term
Using the < s.c.r.i.p.t > tag to include JavaScript inside an html file can affect the loading time of the page. (True / False)
Definition
True
Term
Each individual instruction in a script is known as a statement. Statements should end in a ______. This allows both the human and the computer to understand the code.
(From page 56 of the text)
Definition
Semicolon
Term
Sections of statements called code blocks are surrounded by _________. This creates a group of statements and helps to make scripts more readable.
(From page 56 of the text)
Definition
{ curly braces }
Term
Writing comments inside a script is a way to explain what the code is doing. The JavaScript interpreter carefully reads each comment to get detailed information. (True / False)
(From page 57 of the text)
Definition
False
Term
Single-line comments begin with two forward slash characters. They are usually used to provide short descriptions of what the code is doing. (True / False)
(From page 57 of the text)
Definition
True
Term
Multi-line comments start with /* and end with */. These comments can span many lines and are often used to describe how the script works. (True / False)
(From page 57 of the text)
Definition
True
Term
Computers use _______ to store data for use in computations or for later reference.
(From page 58 of the text)
Definition
Variables
Term
Three data types that JavaScript uses are:

(From page 62 of the text)
Definition
Numeric, String, and Boolean
Term
The following line of code sets a variable to a numeric value:

a) intQuantity = 7;
b) intQuantity == 7
c) intQuantity = "7"

(From page 63 of the text)
Definition
a
Term
Check each line of code that correctly sets strMessage to a string value:

a) strMessage = "Sally said, "hello!" ";
b) strMessage = 'Sally said, "hello!" ';
c) strMessage = "Sally said, \"hello!\" ";

(From page 65 of the text)
Definition
a,b
Term
The following line of code sets a variable to a Boolean value:

a) blnlsBlue == true
b) blnlsBlue = "true";
c) blnlsBlue = true;

(From page 66 of the text)
Definition
c
Term
In JavaScript, the _____ keyword is used to declare variables.

a) create
b) var
c) declare

(From page 67 of the text)
Definition
b
Term
Choose all that apply.
The following rules apply when giving a variable a name.
a) The name must not start with a number
b) All variables are case sensitive
c) The name must not contain a dash or a period
d) Neither keywords nor reserved words can be used
(From page 69 of the text)
Definition
All of the above
Term
_______ is a list of values. It is helpful for storing a list of related items.
(From page 70 of the text)
Definition
An array
Term
The following line of code is an example of _____________.
" var strColors = ['red', 'white', 'blue']; "

a) an array constructor
b) a varlist
c) an array literal
(From page 71 of the text)
Definition
c
Term
The following line of code is an example of __________.
" var strColors = new Array('red', 'white', 'bue'); "
a) an array literal
b) an array constructor
c) a varlist
(From page 71 of the text)
Definition
b
Term
In the following lines of code, the value of strMyFavoriteColor is _____.
a) white
b) red
c) blue
(From page 72 of the text)
Definition
b
Term
Operators and expressions allow programmers to create a single value from one or more values. (True / False)
(From page 74-75 of the text)
Definition
True
Term
Which of the following is NOT a type of JavaScript operator?
a) Assignment operator
b) Comparison operator
c) String operator
d) Logical operator
e)Arithmetic operator
f) Sign operator

(From page 75 of the text)
Definition
f
Term
Check all that apply.
In JavaScript, what does the operator ++ do?
a) It adds two numbers
b) It adds one to the current number
c) It concatenates two strings
(From page 76 of the text)
Definition
b,c
Term
Check all that apply.
In JavaScript, what does the operator + do?
a) It adds one to the current number
b) It adds two numbers
c) It concatenates two strings
Definition
b,c
Term
When evaluating a condition, the result can be a _______.
a) number
b) string
c) Boolean
(From page 150 of the text)
Definition
c
Term
Match each description with its comparison operator.

a) is equal to
b) is not equal to
c) strict equal to
d) strict not equal to
e) greater than
f) less than
g) greater than or equal to
h) less than or equal to
(From page 150-151 of the text)
Definition
a) ==
b) !=
c) ===
d) !==
e) >
f) <
g) >=
h) <=
Term
Comparison operators usually return single values of _________.
(From page 156 of the text)
Definition
either true or false
Term
Match each description with its logical operator.
a) logical AND
b) logical OR
c) logical NOT
(From page 157 of the text)
Definition
a) &&
b) II
c) !
Term
Which statement is NOT true?
The break keyword tells the JavaScript interpreter________.
a) what to do in case of an error
b) that it has finished with a switch statement
c) to go to the first line of code that appears after a loop or switch statement
(From page 164 & 174 of the text)
Definition
a
Term
A switch statement works like a series of if statements. The difference is that the switch statement performs more quickly. (True / False)
(From page 164 of the text)
Definition
True
Term
If your use a data type JavaScript did not expect, it tries to make sense of the operation rather than report an error. It does this with type coercion and weak typing. (True / False)
(From page 166 of the text)
Definition
True
Term
Which statement is NOT true for type coercion?
a) It is not used in JavaScript
b) It creates a need for using strict equally operators
c) It can lead to errors
d) It can lead to unexpected values in your code
(From page 166-168 of the text)
Definition
a
Term
Which of the following is a falsy value?
a) a variable with no value assigned to it
b) strings with content
c) "0"
d) any number that is not zero
e) "false"
(From page 167 of the text)
Definition
a
Term
Which of the following is a truthy value?
a) "false"
b) a variable with no value assigned to it
c) NaN (Not a Number)
d) 0
e) empty value
(From page 167 of the text)
Definition
a
Term
A unary operator returns a result with just one operand. (True / False)
(From page 168 of the text)
Definition
True
Term
There are 3 types of loops: for, while, do while. Match each:
a) for
b) while
c) do while
(From page 170 of the text)
Definition
a) code needs to run a specific number of times
b) code needs to run an unknown number of times
c) code needs to run at least once
Term
An infinite loop is very helpful when dealing with an array. (True / False)
(From page 174 of the text)
Definition
False
Term
Choose 3 correct answers for the statement below.
The Document Object Model (DOM) _____________.

a) is a tree-like structure
b) does not contain objects
c) specifies how JavaScript can change the html page
d) is part of JavaScript
e) specifies how the browser should make a model of the html page
(From page 184 & 186 of the text)
Definition
a, c, e
Term
Choose the 4 main types of DOM nodes.
a) Window Node
b) Browser Node
c) Element Nodes
d) Attribute Nodes
e) Text Nodes
f) The Document Node
g) JavaScript Node
(From page 186 of the text)
Definition
c, d,e,f
Term
Choose 4 correct answers for the statement below.
To access the elements on the DOM tree, JavaScript can be used to select ___________.
a) an individual node by element id
b) a node by its functionality
c) multiple nodes by class
d) multiple nodes by tag name
e) using CSS selector syntax
(From page 188 of the text)
Definition
a, c,d,e
Term
Once an element node or group of nodes is selected, the attributes, the child elements, and the text content can be changed. (True / False)
(From page 189 of the text)
Definition
True
Term
A DOM query can return either one element or a collection of nodes. (True / False)
(From page 192 of the text)
Definition
True
Term
All JavaScript element selection methods are supported equally well in every major browser. (True / False)
(From page 200-202 of the text)
Definition
False
Term
To apply the same code to numerous elements in a NodeList ______________ is a powerful technique. First, it is necessary to determine how many items are in the NodeList. This is done with the ______________________.
(From page 205 of the text)
Definition
looping through, length property of the NodeList.
Term
Once an element node is selected, it is possible to select other nodes related to it. This is called traversing the DOM. New elements can be selected based on their relationship as a parent, sibling, or child of the originally selected element. (Truse / False)
From page 208 of the text)
Definition
True
Term
Some browsers treat whitespace b/w elements as a text node. So, a DOM query can return different elements in different browsers. (True / False)
(From page 209 of the text)
Definition
True
Term
Math each description.
a) nodeValue
b) innerHTML
c) textContent
(From pages 212-218 of the text)
Definition
a) gets or sets text from a specific node
b) gets or sets text & markups but has security risks
c) gets or sets only text from the containing element
Term
There are 2 very different approaches to changing content on a DOM tree: ____________ property and DOM manipulation. ______________ easily targets individual nodes in the DOM tree, whereas _______________ is better suited to updating entire fragments.
(From pages 218-219 of the text)
Definition
innerHTML, DOM manipulation, innerHTML
Term
Using the innerHTML property to change the contents of an element should be avoided because malicious content could be added to the page. (True / False)
(From page 220 of the text)
Definition
True
Term
Which 2 steps must be completed to add an element to the page using DOM manipulation?
a) Format the element - innerHTML property
b) Give the element content - createTextNode()
c) Create the element - createElement()
d) Add the element to the DOM - appendChild()
(From page 222 of the text)
Definition
c,d
Term
To compare the 3 techniques used to add HTML to a web page, match each one to its advantage or disadvantage below.

a) easy way for beginners to learn to add content to the page
b) can be used to add lots of new markup using less code than other options
c) best technique to use when changing one element that has many siblings
d) simple way to remove all content from one element (by assigning it a blank string)
e) using this technique after the page has loaded can cause it to overwrite the entire page
f) does not affect event handlers
g) if many changes are needed, it needs more code and is slower than other methods
(From pages 226-227 of the text)
Definition
a) document.write()
b) element.innerHTML
c) DOM manipulation
d) element.innerHTML
e) document.write()
f) DOM manipulation
g)DOM manipulation
Term
Choose 5 correct responses below.
An event occurs when _________.
a) the DOM has been modified
b) a user hovers/swipes over an element
c) a user clicks or taps on a link
d) a JavaScript function is called
e) a user types on the keyboard
f) a user resizes the window
(From pages 244-247 of the text)
Definition
a,b,c,e,f
Term
a) ________ events occur when the user interacts with the browser's UI rather than the web page.
b) ________ events occur when the user interacts with the keyboard.
c) ________ events occur when the user interacts with the mouse, trackpad, or touchscreen.
d) ________ events occur when an element gains or loses focus.
e) ________ events occur when the user interacts with a form element.
f) ________ events occur when the DOM structure has been changed by a script.
(From pages 246-247 of the text)
Definition
a) User Interface (UI)
b) Keyboard
c) Mouse
d) Focus
e) Form
f) Mutation
Term
Event handling involves 3 steps. List them.
a) Step 1
b) Step 2
c) Step 3
(From page 248 of the text)
Definition
a) Select an element node.
b) Bind an event to the node.
c) Specify the code that is to run.
Term
Event handlers allow the programmer to indicate which event to wait for on any particular element. Match each description.
a) HTML attribute; Old technology - DO NOT USE
b) does not work with IE8 or earlier; can attach multiple functions to an event
c) strong support in all major browsers; can only attach a single function to an event
(From page 250 of the text)
Definition
a) HTML Event Handler
b) DOM Level 2 Event Listener
c) Traditional DOM Event Handler
Term
Event listeners are not supported in some older browsers, so it is necessary to provide fallback code if support for those browsers is necessary. (True / False)
(From page 258 of the text)
Definition
True
Term
Check 3 correct responses.
When an event occurs, the event object tells __________.
a) information about the element that triggered the event
b) the type of event that was fired
c) information about the event
d) what a user is likely to click next
(From page 262 of the text)
Definition
a,b,c
Term
If an HTML page contained an 8x8 table of nodes, creating an event handler for each of the 64 nodes could slow down the page. Fortunately, event flow allows JavaScript to listen for an event on a parent element. A single listener can be created on the parent element, and the event object's target property can be used to determine which bode of the table was clicked.
The process of creating a single listener on a parent event is called ___________.
a) specific listening
b) instantiating the event object
c) event delegation
(From page 266 of the text)
Definition
c
Term
The preventDefault() method of the event object changes the default behavior of an element. This can be used to keep the user on the page after clicking on a link. (True / False)
(From page 267 of the text)
Definition
True
Term
If you can interact with an HTML element, then it can gain or lose focus. Focus and blur events are useful for giving the user feedback as they interact with an individual element. Check 4 examples of focus and blur events.
a) focusin
b) focusout
c) validate
d) tooltip
e) blur
f) focus
(From page 274 of the text)
Definition
a,b,e,f
Term
Mouse events are fired either when the mouse is moved or when its buttons are clicked. However, mouse events cannot be used to change the appearance of an element as the user rolls over it. (True / False)
(From page 276 of the text)
Definition
False (mouse events are often used with CSS to change the appearance of an element as the user rolls over it)
Term
Keyboard events are fired when the user interacts with the keyboard. They fire on any kind of device with a keyboard. Check 4 keyboard events below.
a) keybroken
b) keyup
c) input
d) keypress
e) keydown
(From page 280 of the text)
Definition
b,c,d,e
Term
Match each common use with its corresponding form event.
a) Used to check the values a user has entered into a form before sending it to the server
b) Used when the status of form elements have been altered
c) Used with "< input > " and " < textarea > " elements
(From page 282 of the text)
Definition
a) submit
b) change
c) input
Term
A series of statements that have been grouped together to form a specific task is called _____.
Definition
a function
Term
Choose 5 correct statements about jQuery:
a) jQuery CSS-style selectors are more powerful and flexible than traditional DOM Javascript queries.
b) jQuery can be used to update the DOM tree.
c) jQuery is written in Javascript.
d) jQuery does not use objects.
e) jQuery can be used to attach an event listener to a button.
f) In jQuery, fallback code is needed for compatibility with older browsers.
g) jQuery offers a simple way to achieve a variety of common Javascript tasks quickly and consistently, across all major browsers.
Definition
a,b,c,e,g
Term
Choose 3 correct answers for the statement below.
The jQuery object contains methods that ________.
a) can change the CSS of many elements on the page with a single line of code.
b) can change the background color, change the font, and animate many elements on the page with a single line of code.
c) often change the html file.
d) attach event handlers to specific page elements.
Definition
a,b,d
Term
Choose 2 correct answers for the statement below.
To use jQuery, it is important to ________.
a) remember that jQuery changes the original html file.
b) include the jQuery script after including your own.
c) learn how to use jQuery selectors to select elements.
d) include the jQuery script before including your own code.
Definition
c,d
Term
jQuery's motto is, "Write less, do more," because it allows developers to achieve goals that cannot be done with native Javascript. (True / False)
Definition
False
Term
jQuery can select page elements based on tag name, id attribute, class attribute, or relationship to other page elements. (True / False)
Definition
True
Term
Once a jQuery selection is made, it cannot be narrowed down based on other criteria. (True / False)
Definition
False.
Term
The .text() and .html() jQuery methods can set values for all selected elements. (True / False)
Definition
True
Term
When a selection is made in jQuery, the selection is stored as _______.
a) a copy of the DOM tree nodes.
b) a reference to the DOM tree nodes.
Definition
b
Term
When a jQuery selection needs to be used more than once, _______.
a) caching the selection saves time and valuable resources.
b) it is necessary to repeat the jQuery selection process.
Definition
a
Term
vaar $objListItems = $('l.i').;
The jQuery selection above returns a list of five elements.
If the developer wanted to get the textContent from these elements, ________.
a) it would be necessary to loop through all of the selected elements and retrieve the textContent one at a time.
b) Uh oh. I should have read the chapter.
c) the .each() method can be used because it works like a loop.
d) another language would need to be used. This cannot be done in Javascript.
Definition
c
Term
Placing the script tag for your Javascript code just before the closing body tag allows the HTML to load into the DOM before the script runs. (True / False)
Definition
True
Term
Choose 3 statements below that are true for this jQuery selection.
$('.Flintstone').css('border', '3px solid green');
a) The jQuery selection will put a green border around Fred's text.
b) The jQuery selection will put one large green border around the text of both p elements.
c) This is an example of jQuery selection by class.
d) The jQuery selection will put a green border around Wilma's text.
e) The jQuery selection will not do anything.
Definition
a, c,d
Term
Choose 2 statements below that are true for this jQuery selection.
$('li:last').css('border', '3px solid red');
a) The jQuery selection will not do anything.
b) This is an example of a filtered jQuery selection by tag name.
c) The jQuery selection will place a red box around Pebbles Flintstone's text.
d) The jQuery selection will place one large red box around the entire list.
e) This is an example of jQuery selection by id.
Definition
b,c
Term
The .on() method in jQuery can be used to handle all jQuery events, and it accepts the event as a parameter. (True / False)
Definition
True
Term
Match each jQuery event to the action that causes it to fire.
a) blur g) unload
b) submit h) focus
c) error i) keypress
d) resize j) load
e) select k) scroll
f) ready l) keyup
Definition
a) an element loses focus
b) a form is submitted
c) the browser encounters a Javascript error
d) the browser window has been resized
e) the user selects some text in a form field
f) the document is fully loaded
g) a web page is unloading
h) an element gains focus
i) the user presses a key
j) a web page or node finishes loading
k) the user has scrolled up or down the page or an element
l) the user releases a key on the keyboard
Term
The jQuery .on() method only allows the programmer to specify one event in a single line of code. (True / False)
Definition
False
Term
Check all that apply.
jQuery has effects methods that can ___________.
a) fade in or fade out selected elements.
b) delay animation of selected elements.
c) hide or show selected elements.
d) stop animation of selected elements.
e) slide selected elements.
f) animate multiple elements simultaneously
Definition
all of the above
Term
Choose 3 correct statements below.
Visual effects can be added to web page by _______.
a) using a jQuery plugin.
b) using the jQuery .animate() method.
c) filtering the jQuery selection.
d) traversing the DOM.
e) using jQuery to change the CSS of selected elements.
Definition
a,b,e
Term
jQuery has methods that can be used on forms to get or set the values of input elements or tell whether or not a radio button is checked. (True / False)
Definition
True
Supporting users have an ad free experience!