CSC242, Web Programming Kutztown University, Spring 2015 Mid

advertisement
CSC242, Web Programming
Kutztown University, Spring 2015
1
Mid Term Exam 1 – Chapters 1 to 7
Name: _____________________________
Id: A
Choose the BEST answer that completes each sentence.
Write your answer in the space on the left and circle the letter. They must both match or you only get ½ credit for correct answer.
C 1. The communication standard governing the requests and responses that take place between the browser running on the end
user’s computer and the web server is ____.
a. IP
b. HTML
c. HTTP
d. OSI
e. TCP
A 2. The request/response process consisting of a web browser asking the web server to send it a web page and the web server
sending it back the page uses the ____ model.
a. Client/server
b. Local area network
c. Wide area network
d. Web service
e. Web API
C 3. In order for the compiler to understand PHP code, you have to include ___.
a. <%php … %>
b. <&php … &>
c. <?php … ?>
d. <*php .. *>
e. <php … php>
E 4. The highest level of MySQL structure is a database, within which you can have one or more ___ that contain your data.
a. data structures
b. forms
c. queries
d. rows
e. tables
E 5. In addition to PHP, MySQL, JavaScript, CSS, and HTML5, the other component to creating dynamic web content is ____.
a. AJAX
b. IDE
c. Internet
d. World Wide Web
e. Web server
D 6. PHP is a(n) ____ scripting language.
a. client
b. commercial
c. interpreted
d. server
e. visual studio
E 7. In PHP, the ___ function returns the data type and value of a variable.
a. cout
b. echo
c. print
d. print_r
e. var_dump
CSC242, Web Programming
Kutztown University, Spring 2015
B 8. In PHP, you create a constant using the ____ function.
a. const
b. define
c. global
d. new
e. static
A 9. PHP is considered a(n) ____ typed language.
a. loosely
b. medium
c. no
d. old
e. strongly
D 10. In PHP, all commands must end with a ____.
a. colon (:)
b. comma (,)
c. period (.)
d. semi-colon (;)
e. slash (/)
B 11. In PHP, variables start with a(n) ____ symbol.
a. ampersand (&)
b. dollar ($)
c. hash (#)
d. percent (%)
e. question mark (?)
A 12. Which of the following is not a valid variable name in PHP?
a. 5_highscore
b. _5highSCORE
c. _highscore
d. highScore
e. highScore55
C 13. In PHP, the operator “==” means ____.
a. and
b. assignment
c. is equal to
d. is not equal to
e. identity
C 14. In PHP, string concatenation is represented by the ____ operator.
a. bouble quote (“)
b. dash (-)
c. period (.)
d. plus (+)
e. single quotes (‘)
2
CSC242, Web Programming
Kutztown University, Spring 2015
B 15. PHP offers the ____ as a multiline sequence way of specifying a string literal, preserving line breaks and other white
space in the text.
a. echo
b. heredoc
c. print
d. print_r
e. var_dump
B 16. In PHP, ____ variables are created within a function and can only be accessed within that function.
a. global
b. local
c. logical
d. static
e. super
C 17. In PHP, you can declare a(n) ___ variable that is only accessible within a function that keeps its values for the next
time the function is called.
a. global
b. local
c. static
d. super
e. super global
E 18. The operator with the highest precedence of operation in PHP is the ____.
a. increment
b. logical NOT
c. modulo
d. multiplication
e. parentheses
B 19. Which one is not considered right-to-left associativity?
a. assignment
b. logical AND
c. logical NOT
d. decrement
e. integer casting
E 20. In PHP, the operator “===” means ____.
a. and
b. assignment
c. is equal to
d. is not equal to
e. identity
A 21. In a PHP switch statement, you must end each case with a(n) ____.
a. break
b. continue
c. default
d. else
e. last
3
CSC242, Web Programming
Kutztown University, Spring 2015
C 22. In PHP, the ternary conditional uses the ? and ___ symbols.
a. ampersand (&)
b. exclamation (!)
c. colon (:)
d. greater than (>)
e. less than (<)
E 23. In PHP, single line comments start with ____.
a. <?
b. </
c. /?
d. ??
e. //
A 24. In PHP, you use the ____to exit out of a for loop completely.
a. break
b. continue
c. done
d. exit
e. out
B 25. In PHP, you use the ____to exit out of the current iteration of a for loop and move to the next iteration.
a. break
b. continue
c. done
d. exit
e. out
B 26. In PHP, if you force converting a variable from one type to another, for example (int)($a/$b), this is called ___ casting.
a. default
b. explicit
c. implicit
d. immediate
e. real
C 27. PHP automatically converts values from one type to another whenever required. This is called ____ casting.
a. default
b. explicit
c. implicit
d. immediate
e. real
B 28. In PHP, a(n) ___ allows you to pull out a section of code that is used more than once, and call it when you want to use
the code.
a. for loop
b. function
c. switch statement
d. while loop
e. variable
4
CSC242, Web Programming
Kutztown University, Spring 2015
E 29. In PHP, you use ___ to fetch a particular file and load all its contents.
a. fetch
b. need
c. insert
d. load
e. require
B 30. The most common way to return multiple values from a function is through ____.
a. arguments
b. an array
c. lists
d. local variables
e. static variables
C 31. In OO terminology, a(n) ____ is an instance of a class.
a. constructor
b. method
c. object
d. property
e. sub-class
B 32. In PHP, the method called ____ initializes various properties.
a. __construct
b. __constructor
c. ~construct
d. this
e. static
C 33. In OO terminology, you use the keywords ____and ____ to reference constants directly.
a. Self , @
b. Self , ;;
c. Self , ::
d. Self , #
e. Self , ?
C 34. In PHP, the keyword ____ means that properties and methods can be referenced only by the object’s class methods
and those of any subclasses.
a. assembly
b. public
c. protected
d. private
e. static
A 35. In a(n) ____array, the items in an array are referenced by name rather than by number.
a. associative
b. boolean
c. integer
d. numeric
e. static
5
CSC242, Web Programming
Kutztown University, Spring 2015
6
A 36. In PHP, the foreach loop takes the first item of the array and places it in the variable following the ___ keyword.
a. as
b. each
c. list
d. next
e. this
A 37. In PHP, the array function ____ returns the number of elements in the top level of an array.
a. count
b. list
c. number
d. map
e. sum
A 38. In PHP, the array function ____ creates an array from variables and their values.
a. compact
b. extract
c. list
d. number
e. map
D 39. In PHP, the printf function controls the format of the output by letting you put special formatting characters in
a string. Each printf conversion specifier is prefaced by the ____ symbol.
a. ampersand (&)
b. dollar ($)
c. hash (#)
d. percent (%)
e. question mark (?)
C 40. Sometimes PHP will not have the function you need to perform a certain action, but the operating system that is
running on may. In such cases you can use the ____ system call to do the job.
a. alter
b. code
c. exec
d. run
e. sys
Extra Credit Question
(Up to 6 points) Show a walkthrough example of the foreach loop using a numeric array. Initialize the array with values and print
the result of each loop.
<?php
$myarray = array(“apple”, “orange”, “pear”, “banana”);
$j = 0;
foreach($myarray as $item)
{
echo “$j: $item<br>”;
++j;
}
?>
Download