Final Review Flashcards
Find the error in this code:
SELECT name,
CASE
WHEN imdb_rating > 8 THEN ‘Oscar’
WHEN imdb_rating > 7 THEN ‘Good’
WHEN imdb_rating > 6 THEN ‘Fair’
FROM movies;
A. The column was not renamed.
B. Not enough WHEN/THEN statements.
C. Missing ELSE statement.
D. Missing END statement.
D. Missing END statement.
How would you query all the unique genres from the books table?
A. SELECT DISTINCT genres
FROM books;
B. FROM books
SELECT DISTINCT genres;
C. SELECT UNIQUE genres
FROM books;
D. SELECT genres
FROM books;
A. SELECT DISTINCT genres
FROM books;
T/F. IS NULL condition returns true if the field is empty.
True
What code would you add to this query to order colors by name alphabetically (Z to A)?
SELECT *
FROM colors
_________________;
A. ORDER BY name ASC
B. GROUP BY name ASC
C. ORDER BY name DESC
D. ORDER BY name
C. ORDER BY name DESC
What does the wildcard character % in the following SQL statement do?
SELECT *
FROM sports
WHERE name LIKE ‘%ball’;
A. It matches all sports that begin with ‘ball’.
B. It matches all sports that contain ‘ball’.
C. It matches all sports that have a pattern like ‘ball’, such as ‘b3ll’ and ‘b@ll’.
D. It matches all sports that end with ‘ball’.
D. It matches all sports that end with ‘ball’.
What is LIKE?
A. A clause used to bookmark columns that are frequently queried.
B. A clause used to select unique values from a table.
C. A special operator that can be used with the WHERE clause to search for a pattern.
D. A statement that allows us to create different outputs.
C. A special operator that can be used with the WHERE clause to search for a pattern.
What is LIMIT?
A. A clause that restricts our query results in order to obtain only the information we want.
B. A clause that is used to return unique values in the output.
C. A clause that lets you specify the maximum number of rows the result set will have.
D. A clause that lets you specify the maximum number of columns the result set will have.
C. A clause that lets you specify the maximum number of rows the result set will have.
What is ORDER BY?
A. A clause that allows you to select unique values.
B. An operator used with the WHERE clause.
C. A clause that sorts the result set alphabetically or numerically.
D. A clause that sorts the result set in alphabetical order only.
C. A clause that sorts the result set alphabetically or numerically.
What is the correct query to select only the cities with temperatures less than 35?
A. SELECT *
FROM cities
WHERE temperature < 35;
B. SELECT *
FROM cities
WHERE temperature = 35;
C. SELECT *
FROM cities;
D. SELECT *
FROM cities
WHERE temperature != 35;
A. SELECT *
FROM cities
WHERE temperature < 35;
What is the correct syntax to query both the name and date columns from the database?
SELECT __________
FROM album;
A. name & date
B. name, date
C. name; date
D. name + date
B. name, date
Which of the following is NOT a comparison operator in SQL?
A. ~
B. <
C. >=
D. !=
A. ~
Which operator would you use to query values that meet all conditions in a WHERE clause?
A. AND
B. OR
C. BETWEEN
D. LIKE
A. AND
Choose the correct explanation for the include statement in PHP.
A. include checks if a value is included in an array.
B. include brings in and evaluates code from one file to another.
C. include allows a global variable to be used within a function.
B. include brings in and evaluates code from one file to another.
Fill in the code so that “Great job!” prints to the terminal.
if (“cat” [_______] “dog”){
echo “Great job!”;
}
A. !== B. > C. ! D. = E. ===
A. !==
Fill in the code so that “Great job!” prints to the terminal.
if (1 [_________] 10){
echo “Great job!”;
}
A. = B. > C. & D. >= E. < F. ===
E.
Fill in the code so that “Great job!” prints to the terminal.
if (10 [________] 10){
echo "Great job!";
}
A. < B. = C. === D. !== E. >
C. ===
Fill in the code so that “Great job!” prints to the terminal.
if (10 [________] 10){
echo "Great job!";
}
A. >
B. <
C. !==
D. >=
D. >=
Fill in the code so that “Great job!” prints to the terminal.
if (10 [________] 10){
echo "Great job!";
}
A. > B. = C. < D. !== E. <=
E. <=
Fill in the code so that “Great job!” prints to the terminal.
if (10 [_____] 3){
echo “Great job!”;
}
A. > B. = C. & D. < E. <= F. ===
A. >
The following variables hold what type of values?
$first = TRUE; $second = FALSE;
A. Booleans
B. Floats
C. Strings
D. Arrays
A. Booleans
What will the following code output to the terminal?
$first = TRUE;
$second = FALSE;
$third = TRUE;
if ($first) {
if ($second){
echo "Option 1";
} else {
echo "Option 2";
}
} elseif ($third) {
echo "Option 3";
} else {
echo “Option 4”;
}
Option 4
What will the following code output to the terminal?
$happy = TRUE;
if ($happy) {
echo “I’m so happy right now!”;
}
A. TRUE
B. $happy
C. I’m so happy right now!
D. Nothing
C. I’m so happy right now!
What will the following code output to the terminal?
$letter = “h”;
switch ($letter) {
case “h”:
echo "h";
case “e”:
echo "e";
case “l”:
echo "l";
case “x”:
echo "l";
case “o”:
echo "o";
}
A. hel
B. helo
C. hello
D. h
hello
What will the following code output to the terminal?
$mood_color = “red”;
switch ($mood_color){
case "green": echo "You're feeling happy."; break; case "yellow": echo "You're feeling energized."; break; case "black": echo "You're feeling scared."; break; case "red": echo "You're feeling angry."; break;
}
A. You’re feeling energized.
B. You’re feeling scared.
C. You’re feeling happy.
D. You’re feeling angry.
D. You’re feeling angry.
What will the following code output to the terminal?
$mood_color = “red”;
switch ($mood_color){
case "green": echo "You're feeling happy."; break; case "yellow": echo "You're feeling energized."; break; case "black": echo "You're feeling scared."; break; case "red": echo "You're feeling angry."; break;
}
A. You’re feeling angry.
B. You’re feeling energized.
C. You’re feeling happy.
D. You’re feeling scared.
A. You’re feeling angry.
What will the following code return?
$score = 77;
if ($score < 60) {
return “F”;
} elseif ($score < 70) {
return “D”;
} elseif ($score < 80) {
return “C”;
} elseif ($score < 90) {
return “B”;
} else {
return “A”;
}
A. "A" B. "B" C. "C" D. "D" E. "F"
“C”
What will the following print to the terminal?
$happy = FALSE;
if ($happy){
echo “I’m so happy right now!”;
} else {
echo “I’m so sad…”;
}
A. FALSE
B. I’m so sad…
C. Nothing
D. I’m so happy right now!
B. I’m so sad…
“PHP runs on different platforms (Windows, Linux, Unix, etc.)”
A. Only on Windows
B. Only on Mac
C. Only on Linux/Unix
D. All operating systems mentioned above
D. All operating systems mentioned above
A PHP script should start with ___ and end with ___:
A. < php >
B. < ? php ?>
C.
D.
D.
How do you display a double quote inside a string that begins and ends with double quotes?
A. Just include the double quote “, for example “He said “OK””
B. Use ", for example “He said "OK"”
C. Use =”, for example “He said =”OK=””
D. You cannot display “ inside a string that begins and ends with double quotes!
B. Use ", for example “He said "OK"”
Look at the following HTML form, then decide which one of the following statements is correct.
<p>Please enter your zip code:
</p>
A. When the processor executes zip-it.php, the zip code submitted by the user can be extracted from $_POST[‘zip-it’]
B. When the processor executes zip-it.php, the zip code submitted by the user can be extracted from $_POST[‘$zip-it’]
C. When the processor executes zip-it.php, the zip code submitted by the user can be extracted from $_POST[‘zipCode’]
D. When the processor executes zip-it.php, the zip code submitted by the user can be extracted from $_POST[‘$zipCode’]
E. When the processor executes zip-it.php, the zip code submitted by the user can be extracted from $_POST[‘zip code’]
C. When the processor executes zip-it.php, the zip code submitted by the user can be extracted from $_POST[‘zipCode’]
PHP scripts are executed on _______
A. ISP Computer
B. Client Computer
C. Server Computer
D. It depends on PHP scripts
C. Server Computer
PHP variable names must begin with
A. A lower-case letter
B. An upper-case letter
C. A dollar sign $
D. A number
C. A dollar sign $
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>”);
A. <p>Allow 20 hours for study</p>
B. <p>Allow hours for study</p>
C. <p>Allow $studytime hours for study</p>
D. <p>Allow 0 hours for study</p>
D. <p>Allow 0 hours for study</p>