/*
* info.php
*
* Computer Science 50, Fall 2011
* section10
*
* Defines all the questions and answers.
*/
// define a class for a square (question + answer)
class Square
{
// square's question
public $question = NULL;
// square's answer
public $answer = NULL;
}
// instantiate a square object (c = category, v = value)
$c1v100 = new Square();
// set question and answer for particular square
$c1v100->question = "Why is passing by reference better than passing by value?";
$c1v100->answer = "The callee is able to change the argument.";
// repeat over and over again to fill up all the squares of the jeopardy board
$c2v100 = new Square();
$c2v100->question = "True or False.
Both JavaScript and PHP are interpreted languages.";
$c2v100->answer = "True";
$c3v100 = new Square();
$c3v100->question = "Valgrind returns the following: invalid write of size 4. What happened?";
$c3v100->answer = "You have likely written to a 4-byte location in memory that does not belong to you.";
$c4v100 = new Square();
$c4v100->question = "What's an event handler?";
$c4v100->answer = "A function that is called in response to some event.";
$c5v100 = new Square();
$c5v100->question = "If you don't use Facebook, are you still safe from session hijacking (i.e. what Firesheep does)?";
$c5v100->answer = "No. Any website that transmits session cookies in the clear is vulnerable.";
// 200 level
$c1v200 = new Square();
$c1v200->question = "What's the difference between NULL and \0?";
$c1v200->answer = "NULL is a special pointer that points to no object.
The null terminator is a char that generally demarks the end of a string.";
$c2v200 = new Square();
$c2v200->question = "What's the difference between GET and POST?";
$c2v200->answer = "GET allows the state of a page to be bookmarkable.
POST affords data more privacy.";
$c3v200 = new Square();
$c3v200->question = "What's steganography?";
$c3v200->answer = "The science of hiding information.";
$c4v200 = new Square();
$c4v200->question = "What function executes a SQL query in PHP?";
$c4v200->answer = "mysql_query();";
$c5v200 = new Square();
$c5v200->question = "What's 00010000 in hexadecimal?";
$c5v200->answer = "0x10";
// 300 level
$c1v300 = new Square();
$c1v300->question = "What does sizeof(long long) return?";
$c1v300->answer = "8";
$c2v300 = new Square();
$c2v300->question = "What's AJAX?";
$c2v300->answer = "A technique whereby webpages can request additional data from a server without having to reload entirely.";
$c3v300 = new Square();
$c3v300->question = "What's an API?";
$c3v300->answer = "An API is an interface written by programmers that other programmers can use in their own software.";
$c4v300 = new Square();
$c4v300->question = "Write a function that takes a positive integer and returns true if it is even.";
$c4v300->answer = "bool even(int n) { if (n % 2 == 0) return true; else return false; }";
$c5v300 = new Square();
$c5v300->question = "Why might a hash table be better than a trie?";
$c5v300->answer = "A hash table should be used when you have a sparse data set as the nodes of a trie would likely take up much more space.";
// 400 level
$c1v400 = new Square();
$c1v400->question = "In C, what code would you write to typedef the node of a binary search tree?";
$c1v400->answer = "typedef struct node { int n; struct node *left; struct node * right; } node;";
$c2v400 = new Square();
$c2v400->question = "When are SQL injection attacks possible?";
$c2v400->answer = "When user-supplied input is not escaped before use in a SQL query.";
$c3v400 = new Square();
$c3v400->question = "For what purpose are regular expressions useful?";
$c3v400->answer = "Pattern matching or the extraction of substrings.";
$c4v400 = new Square();
$c4v400->question = "What's the difference between a while and a do-while loop?";
$c4v400->answer = "A do-while loop executes its code at least once.";
$c5v400 = new Square();
$c5v400->question = "What's the upper bound on the running time of inserting an integer into a sorted linked list?";
$c5v400->answer = "O(n)";
// 500 level
$c1v500 = new Square();
$c1v500->question = "What's wrong and how can you fix it: char *s = "hello"; printf("%s", *s);";
$c1v500->answer = "Printf expects a pointer to a char as its second argument, but *s denotes a char and will incorrectly be interpreted as an address.
To fix, change *s to s.";
$c2v500 = new Square();
$c2v500->question = "What's two-factor authentication?";
$c2v500->answer = "Two-factor authentication involves challenging a user to present two forms of identification in order to proceed.";
$c3v500 = new Square();
$c3v500->question = "What's the difference between design and style anyhow?";
$c3v500->answer = "...";
$c4v500 = new Square();
$c4v500->question = "Write a function in C that returns false unless its argument is an uppercase letter.";
$c4v500->answer = "bool isupper(char c) { if (c >= 65 && c <= 90) return true; else return false; }";
$c5v500 = new Square();
$c5v500->question = "If global variables are accessible by all functions, why bother with local variables?";
$c5v500->answer = "Using only global variables increases the risk that some functions might change their values unbeknowst to other functions.
It also makes code less readable.";
// fill a new associative array with all of the squares
$array = array(
"c1v100" => $c1v100,
"c2v100" => $c2v100,
"c3v100" => $c3v100,
"c4v100" => $c4v100,
"c5v100" => $c5v100,
"c1v200" => $c1v200,
"c2v200" => $c2v200,
"c3v200" => $c3v200,
"c4v200" => $c4v200,
"c5v200" => $c5v200,
"c1v300" => $c1v300,
"c2v300" => $c2v300,
"c3v300" => $c3v300,
"c4v300" => $c4v300,
"c5v300" => $c5v300,
"c1v400" => $c1v400,
"c2v400" => $c2v400,
"c3v400" => $c3v400,
"c4v400" => $c4v400,
"c5v400" => $c5v400,
"c1v500" => $c1v500,
"c2v500" => $c2v500,
"c3v500" => $c3v500,
"c4v500" => $c4v500,
"c5v500" => $c5v500,
);
?>