160 Exam
Which of the following is the "not identical " operator?
!==
Study the following algorithm. What is the least number of times this loop might repeat? Set count to 1 Turn a card over WHILE (card != Jack) Add 1 to count Turn a card over ENDWHILE Display count
0
The first option in a select menu has an index value of _____.
0
How many lines will these statements store in the file referenced by the variable fputs($someFile, "Test"); fputs($someFile, "One, two, three");
1
How many times will the following loop repeat? for ($count = 3; $count < 5; $count = $count + 2) { print ("<p>Hello!</p>"); }
1
Traditional event handlers are limited in that they can only be used to assign _____ event handler(s) to a specific event on a specific object at a time.
1
December is represented in a Date object as _____.
11
How many paragraphs will the following HTML code display? <p>Current HTML standards are defined by the <a href="http://www.w3.org/">World Wide Web Consortium</a></p><p>Be sure to follow the current standards!</p>
2
How many times will the following loop repeat? for ($count = 1; $count <= 20; $count = $count + 10) { print ("<p>Hello!</p>"); }
2
How many values will the user submit each time this form is used? <form action = "process.php" method = "post" > <p>Color: <select name="color"> <option>Red</option> <option>Blue</option> <option>Green</option> </select></p> <p>Quantity:<input type="text" size="10" name = "qty"></p> <input type="submit" value="Submit Order" /> </form>
2
If you want to add one block of JavaScript code to an HTML page and also include an external JavaScript file, how many instances of the script tag will be required?
2
If $hourlyWage contains the value 20.00 and $hoursWorked contains the value 30, what value will $bonus contain after the following code is executed? if ($hourlyWage > 20 or $hoursWorked < 40) $bonus = $25.00; else $bonus = $50.00;
25
If $hourlyWage contains the value 20.00 and $hoursWorked contains the value 30, what value will $bonus contain after the following code is executed? if ($hourlyWage >= 20 or $hoursWorked <= 30) $bonus = $25.00; else $bonus = $50.00;
25
How many COLUMNS will be displayed in this table? print ("<table border = \"1\">"); for ($count = 1; $count <=10; $count = $count + 1) { $result1 =$count * 10; $result2 =$count * 100; print("<tr><td>$count</td><td>$result1</td> <td>$result2</td></tr>"); } print ("</table");
3
How many different paths are there through this code segment? if ($carsSold < 20) $bonus = 50.00; elseif ($carsSold < 30) $bonus = 100.00; else $bonus = 200.00;
3
How many output values are indicated in the following requirement? REQUIREMENT: Write a program that asks the user for the current temperature and wind speed. The program must calculate the wind chill temperature, and display a chart showing the temperature, wind speed, and wind chill.
3
How many times will the following loop repeat? for ($count = 0; $count < 3; $count = $count + 1) { print ("<p>Hello!</p>"); }
3
How many times will the following loop repeat? for ($count = 1; $count < 10; $count = $count + 3) { print ("<p>Hello!</p>"); }
3
How many rows and columns will be displayed by this table? <table border = "1" > <tr><td>France</td><td>Paris</td></tr> <tr><td>England</td><td>London</td></tr> <tr><td>Italy</td><td>Rome</td></tr> </table>
3 rows & 2 columns
What value is stored in $result after these PHP instructions are executed? $value1 = 15; $value2 = 10; if ($value1 > $value2) $value2 = 15; $result = $value1 + $value2; print("<p>The result is $result</p>");
30
What is the highest index position in the $sales array after the following statements are processed? $sales = array(10, 20, 50); $sales[] = 20; $sales[] = 40;
4
If $hourlyWage contains the value 20.00 and $hoursWorked contains the value 30, what value will $bonus contain after the following code is executed? if ($hourlyWage >= 20 and $hoursWorked < 30) $bonus = $25.00; else $bonus = $50.00;
50
If an array named $cityNames is indexed from 0 to 5, what value would sizeof($cityNames) return?
6
Consider the following code. What bonus will be assigned to an employee who has worked 5 years and earns 16000.00? if ($yearsWorked < 5) { if ($salary < 18000.00) $bonus = 500.00; else $bonus = 400.00; } else $bonus = 750.00;
750.00
What does a proper HTML5 DOCTYPE look like?
<!DOCTYPE html>
Read this carefully. What HTML code is generated by the print statement? $numCourses - 4; $studyTime - $numCourses * 5; print ("<p>Allow studyTime hours for study</p>");
<p>Allow 20 hours for study</p>
What HTML output will be generated by the following PHP code? $inventory = 47; if ($inventory < 40) print("<p>Time to re-order!</p>"); else { $countdown = $inventory - 40; print("<p>Countdown to re-order: $countdown.</p>"); }
<p>Countdown to re-order:7</p>
What is the assignment operator?
==
What does a compiler do?
Converts source code into an executable file
What is the purpose of the PHP sizeof() function?
Determine the number of elements in an array.
Consider the following code? Which employees will get a 400.00 bonus? if ($yearsWorked < 5) { if ($salary < 18000.00) $bonus = 500.00; else $bonus = 400.00; } else $bonus = 750.00;
Employees who have worked less than 5 years, with a salary of at least 18000.00.
Suppose your standalone Web server is installed on a USB drive in location H:\xampp. Which folder does the localhost domain actually point to by default?
H:\xampp\htdocs
The target or srcElement property refers to _____.
HTML element that triggered the event
What is wrong with the following URL? http:\\www.myweb.com\images\home.html
Internet addresses must use the forward slash / as a separator.
Consider the following code: $listFile =fopen("member-list.txt","r"); $someValue = fgets($listFile); fclose($listFile); Assume member-list.txt contains the following two lines of text: Mary:King Peter:Jones What does $someValue contain after these statements are executed?
Mary:King
Assume somefile.txt contains the following text on two lines: Mary:King Peter:Jones What will the file contain after the following instructions are executed? $someFile =fopen("somefile.txt","a"); fputs($someFile, "Ann:Porter\n"); fputs($someFile, "Dennis:Smith\n"); fclose($someFile);
Mary:King Peter:Jones Ann:Porter Dennis:Smith
Which of the following is a common cause of errors?
Not porperly capitalizing a variable or function name
What does the explode() function do?
Takes a delimiter and a character string as arguments and parses the string based on the delimiter to return an array of values.
What is wrong with the following piece of PHP code? if ($password = "xyz") print("<p>That's the correct password!</p>");
The = should be ==
What is the computer's instruction set?
The basic set of commands that a computer can execute
What is wrong with the following URL? http://images/www.myweb.com/home.html
The domain name is the wrong location.
What can you determine about the contents of some-data.txt if you know that the following code is correct? $value = 0; $someFile =fopen("some-data.txt","r"); $nextItem = fgets($someFile); while (!feof($someFile)) { list($item1, $item2) = explode(":", $nextItem); $value = $value + $item1; $nextItem = fgets($someFile); } fclose($someFile); print ("<p>$value </p>");
The file contains two values on each line, the first value is a number.
Which statement is true? C:\Projects\Website\index.html Which statement is true?
The file is stored in the folder named Website
The fgets() statement is missing from this loop? What will happen? $numbersFile =fopen("numbers.txt","r"); $number = fgets($numbersFile); while (!feof($numbersFile)) { print ("<p>$number</p>"); } fclose($numbersFile);
The loop will keep printing the first number in the file.
Only employees who work at least 40 hours are to receive a $100 bonus. What is wrong with the logic of the following code? if ($hoursWorked >= 40) { print ("<p>You qualify for a bonus! </p>"); } $bonus = 100;
The statement assigning 100 to $bonus should appear INSIDE the IF structure.
Study the following algorithm. The instruction "Turn a card over" appears twice. Why does it appear the first time, before the loop structure? Set count to 1 Turn a card over WHILE (card != Jack) Add 1 to count Turn a card over ENDWHILE Display count
This ensures that the loop condition has a card to test the very first time.
What is wrong with this code? $listFile =fopen("member-list.txt","r"); fputs($listFile, $newMember); fclose($listFile);
To use fputs() you must open the file for write or append operations.
How do you display a double quote inside a string that begins and ends with double quotes?
Use \", for example "He said \"OK\""
A test that evaluates to true or false is known as
a boolean expression
PHP variable names must begin with
a dollar sign $
Which of the following lines of code will reliably provide a reference to the event that occurred?
all answers are correct
Which of the following methods and constants are defined within the Math object?
all answers are correct
Which of the following is not an advantage of the HTML5 DOCTYPE?
all of answers are correct
What benefits does Ajax bring to Web sites?
all of the answers are correct
Which of the following is a reason why you should not use inline event handlers?
all of the reasons
Which of the following should you consider when choosing development software?
all of these answers are correct
To remove a traditional event handler, _____.
assign the value null to the event property
Which of the following represents dot notation or object notation?
both are correct
How does the Web browser handle white space (multiple spaces, tabs, blank lines, indents) in your HTML document?
browser ignores white space
How do you remove the options in a select menu?
by invoking removeChild() for each option
Which of the following is not an Ajax debugging step?
change the css
Through what property can you confirm that a checkbox was checked?
checked
Which of the following is not an input device event?
copy
The numbers.txt file contains a list of numbers, one on each line. What does this code do? $result = 0; $numbersFile =fopen("numbers.txt","r"); $number = fgets($numbersFile); while (!feof($numbersFile)) { $result = $result + 1; $number = fgets($numbersFile); } fclose($numbersFile); print (<p>RESULT: $result</p>");
counts the numbers
How do you add options to a select menu?
creating elements & using appendChild()
What is wrong with the following piece of PHP code? if ($carsSold >10) print("<p>Good job - You get a bonus!</p>"); $bonus = 500.0; else print("<p>Sorry - no bonus..</p>");
curly brace are needed in the IF section
What is important about persistent data?
data remains available after a program has ended
Which of the following does not fall under code intelligence?
debugging
A variable would be global if it is _____.
defined outside of any function
Look at the following form. Which input method is the form using to receive the user's favorite activity? <form action = "calculate.php" method = "post" > <p>What is your favorite activity? <select name = "activity"> <option>Running</option> <option>Swimming</option> <option>Cycling</option> </select> </p><p><input type = "submit" value = "Submit" ></p> </form>
drop down list
If a variable named $carsSold contains the value 25, what is the result of this test?
false
JavaScript and Java are related languages.
false
String comparisons are case-insensitive.
false
The indexOf() and lastIndexOf() methods perform case-insensitive searches.
false
Variables in JavaScript must be declared.
false
In case the device accessing a page does not have an input device, the mouseover event should be paired with a _____ event.
focus
Recursion occurs when _____.
function calls itself
The following code processes a file containing five positive numbers. What will the variable $result contain after the code is executed? $result = 0; $someFile = fopen("some-file.txt", "r"); for ($count = 1; $count <= 5; $count = $count + 1) { $nextNum = fgets($someFile); if ($nextNum > $result) $result = $nextNum; } fclose($someFile); print ("<p>The result is $result</p>");
highest of the five numbers in the file
Suppose your standalone Web server is installed on a USB drive in location H:\xampp. What would be the correct URL for a file stored in the following location: H:\xampp\htdocs\webtech\coursework\chapter02\my-work.html
http://localhost/webtech/coursework/chapter02/my-work.html
Given the following requirements which would be the appropriate test to use? A discount of 10% should be applied if either of the following conditions apply: The customer has ordered at least 10 copies The item cost is above 25.00
if ($numCopies >= 10 or $itemCost > 25.00)
Consider the following address: C:\Projects\Website\index.html What is the name of the file?
index.html
An instruction to obtain information from the user is an example of:
input statement
Consider the following instructions carefully. What is wrong? Drive to the store Pay the cashier Select your purchases Drive home
instructions are not correctly ordered
To reliably find the key pressed, you should watch for _____ events.
keydown or keyup
To reliably find the character entered, you should watch for _____ events.
keypress
A file named member-list.txt contains the string "Mary:King" on a single line. Assume you already have written the following code: $listFile =fopen("member-list.txt","r"); $someValue = fgets($listFile); fclose($listFile);
list($firstName, $lastName) = explode (":", $someValue);
HTML is an example of:
markup language
A function's parameters can have _____.
none of the answers are correct
What is wrong with this code segment if ($ticket != "jackpot") { print("<p>Sorry - try again?</p>"); else print ("<p>You WON!!!</p>"); $winnings = $123456789.00 }
opening brace should appear AFTER the ELSE
Nesting conditionals are the act of _____.
placing one conditional within another
Which of the following is not a method that adds one or more elements to an array?
pop()
An Ajax request that results in a database record being updated would use _____ as the request type.
post
If a PHP script returns XML or JSON, it must first send _____.
proper content-type header
What type of operation is used to obtain data from a file?
read operation
What is the priming read?
read statement that occurs before a WHILE NOT EOF loop
What does this code actually do? $result = 0; $someFile =fopen("some-data.txt","r"); $nextItem = fgets($someFile); while (!feof($someFile)) { list($name, $booksOverdue) = explode(":", $nextItem); if ($booksOverdue > 0) $result = $result + 1; $nextItem = fgets($someFile); } fclose($someFile); print ("<p>$result </p>");
reads a file and counts # of people who have books overdue
The first argument to the open() method is:
request method
Look at the following form. What is the name of program that will be executed when this form is submitted? <form action = "retire.php" method = "post" > <p>What is your age?<input type="text" size="10" name="age"></p> <p><input type="submit" value = "Calculate " ></p> </form>
retire.php
What keyword is used to have a function return a value when called?
return
Which of the following conditions likely contains a bug?
s2.indexOf(s1);
Where on your disk is the file indicated by the URL: http://localhost/webtech/samples/some-file.html?
samples folder which is located under xampp\htdocs\webtech\
What method is called in order to actually perform the Ajax request?
send()
What is an algorithm?
set of instructions to meet requirement of some kind
Programming instructions written in a programming language are known as:
source code
What language is commonly used to directly communicate with a Database Management System (DBMS)?
sql
What event should you almost always use to handle form submissions?
submit
Which of the following methods are defined within the Number object?
toFixed()
An array can contain other arrays as array elements.
true
True or False? If a program has been compiled, the user does not have access to the source code and cannot change the program.
true
Variable names in JavaScript are case-sensitive.
true
You can omit the curly braces in control structures in JavaScript.
true
You can use multiple instances of the script tag within the same HTML page.
true
What phrase is commonly used to describe testing an application to ensure that it can be understood easily by the intended audience?
usability testing
Through what property can you obtain the option selected in a select menu?
value
What is JS Bin?
web site for writing & testing Javascript code