CGS Exam 3
The JavaScript code contains a function convertPrice(), which converts the price from one currency to another. What is the correct way to call convertPrice() when the amount field is changed?
$("#amount") .change(convertPrice);
Register a call back function doThis() that gets triggered when the mouse double-clicks on an element with ID "button".
$("#button") .on ("dblclick", doThis);
Which line of code adds 2 classes, "first" and "last", to the elements with ID "section"?
$("#section") .addClass ("first last");
which line of code removes the class "big-font" from all <h1> elements?
$("h1") .removeClass("big-font")
Which line of code adds class "highlight" to all <li> tags that descent from a <ul> tag?
$("ul li") .addClass("highlight");
What can replace "jQuery()" in a function call?
$()
What is the shortened version of $ (document) .ready(displayMessage);?
$(displayMessage);
What is needed to output Ella's bread? $cows = ["Ella" => "Holstein", "Larry" => "Mixed", "Kelsey" => "Herford"]; foreach ($cows as _______) { echo "$cow's breed is $breed.\n"; }
$cow => $breed
What is needed to output Ella's bread? $cows = ["Ella" => "Holstein", "Larry" => "Mixed", "Kelsey" => "Herford"]; echo ________;
$cows["Ella"]
Which is a valid PHP variable name?
$first_name
What loop condition will print the numbers 1 2 3 4 5 for ($i = 1; ______; $i++) { echo "$i "; }
$i < 6
What is missing from the following PHP script tp print the name of the webpage? <!Doctype html> <html> title Hello PHP title body ?php $name = "PHP"; echo "<h1>Hello, ____! </h1>"; ?> /body /html
$name
When the form is submitted, how would the order be accessed in the PHP?
$order = $_POST["order"]"
What is needed to output "Ghostbusters"? $quiz = [ [ "question" => "Who is John Galt?", "answer" => "We are!", "points" => 5 ], [ "question" => "Who you gonna call?", "answer" => "Ghostbusters", "points" => 5 ] ];
$quiz[1] ["answer"]
What statement returns today's date in PHP?
$today = date_create("today");
Complete the code to output the number 20. function swap (_____) { $temp = $x; $x = $y; $y = $temp; } $a = 10; $b = 20; swap ($a, $b); echo $a;
&$x, &$y
What value is x after the code segment? if ("1" ==== 1) { $x = 0; } elseif ("1" > 1) { $x = 1; } else { $x = -1; }
-1
What event is helpful for writing a callback function that ensures that the first name field was filled in when the user starts filling in the last name field?
focus
What constructor assigns a default value to title for the Movie class?
function ____construct($title = "undefined") { $this->title = $title; }
The ______ statement inserts the contents of a file into a PHP script as the script is executing.
include
Given the statement require "myfile.php"; where is the first place PHP looks for the file?
include path from php.ini
which expression evaluates to true if a user selects a radio button named selectMe?
isset($_POST["selectMe"])
A ______ is a collection of _________ that focus on a related set of tasks.
library, functions
What is needed to call the function to populate three variables? function special_nums() { return [3.142, 2.718, 1.618]; }
list($pi, $euler, $phi) = special_nums();
What is needed to allow the code to execute properly? class Movie { ______ } $movie = new Movie; $movie->title = "Nurse Betty";
public $title;
Given teh array $teams = ["Raiders", "Chargers", "Broncos", "Chiefs"]; what function call puts the array in the following order: Raiders, Chiefs, Chargers, Broncos?
rsort($teams);
PHP runs on the ___, while JavaScript runs on the ____
server-side, client side
What is needed to determine the length of a string in PHP?
strlen($myString)
What does the expression evaluate to? ('a' < 'b' && 5 > 0);
true
How many times does the while loop execute the loop body? $c = 0; while ($c < 2) { echo $c; $c + = 1; }
two
why is client-side validation important?
Prevents XSS attacks
What does the PHP script output if $name is not initialized ?php error reporting E_ALL; ini_set "display errors", 1); echo " p What is displayed </p>"; echo $name; ?>
Runtime message of a possible logic error
If the text area element shown is sent to a server running PHP, what will $_GET["order"]contain when the form's method is GET? <textarea name="order">Tea Bags</textarea>
Tea Bags
What value is $y $y = 7 + "3" * 2 - 2
11
What value is $x if ("he" > "hello") { $x = 1; } else if ("he" <= "hello") { $x = 2; } else { $x = 0; }
2
What is the last number output? $i = 1; do { echo "$i "; $i++; } while ($i <= 4); echo $i;
5
What value is $x? $x = 12; $x /= 3 - 1;
6
What is the output of the PHP code segment? myFun(3); myFun(3, 5); function myFun($opA, $opB = 4) { $opC = $opA + opB; echo "$opC "; }
7 8
What is needed to compare two DateTime objects for equality? if (date1 ______ date2) { echo "Date/times are the same"; }
==
What can be inferred about the jQuery library in this line of code? script src="jquery-3.5.0.min.js
This library was minified to reduce the file size
which jQuery selector type is $("li:last")?
Basic Filter selector
A/an_____ provides benefits lacking in JavaScript like type safety, simplified class creation, and module creation
Compile-to-Javascript Language
Document databases store documents in _____ format with many levels of nesting.
JSON
In jQuery, when is the ready event triggered?
Once the document object model has been loaded
What is $dog1->name after the code segment executes? $dog1 = new Dog; $dog1-> name = "Dolly"; $dog2 = $dog1; $dog2->name = "Ella"; $dog3 = new Dog; $dog3->name = "RussT"
Ella
What will happen if the color.php file is missing? require "./color.php"; $color_code = 3;
Fatal error and script stops
What does the PHP code segment output? ?php $x = "Hello"; echo "Hello \$x " ?>
Hello $x
What value is $x $value = "Hello"; switch ($value) { case "Hello"; $x = "Hello"; case "cheese"; $x .= "Hi"; break; default; $x = "Default"; }
HelloHi
What does the code output? $question = "How are you?", ask question(); function askQuestion() { $question = "What question?"; echo $question; }$question = "Who are you?";
What question?
Dog inherts from class Animal. Which property (s) can be directly accessed by class Dog?
age, name
A single page application (SPA) initially loads______
all of the application's resources
How does class Dog inherit from a class Animal?
class Dog extends Animal
Representing, storing, and retrieving application data in relation and non relational databases is called ______
data modeling
if (strcmp($greeting, $salute) < 0) { $x = "yes"; } else { $x = "no"; } echo $x;
yes
How many time does the while loop execute the loop body? $c = 100; while ($c < 0 ) { echo $c; $c += 10; }
zero