LIS4381 P2
To refer to a public property name categoryName for an object that's referenced by $category, you code a. $category->categoryName b. $category->$categoryName c. $category::categoryName d. $category::$categoryName
a. $category->categoryName
____________________________ are variables associated with an object. a. Properties b. Components c. Elements d. Parameters
a. Properties
To avoid the duplication of function names, you can a. Use namespaces b. Use libraries c. Store function files in lower-level directories d. Use include paths
a. Use namespaces
If you create a function that passes an argument by reference, the function a. can change the original variable without using a return statement b. can change the variable and pass it back by using a return statement c. can't change the variable d. must make a copy of the variable before it changes it
a. can change the original variable without using a return statement
When you use inheritance to create a new class from an existing class, the new class starts with the public properties and __________________________________ of the existing class. a. constants b. objects c. properties d. result sets
a. constants
In PHP, all functions have ___________________________ scope. a. global b. local c. both local and global d. reference
a. global
Class members that other programmers do not need access to should be _________________________________. a. hidden b. deleted c. saved d. copied
a. hidden
Use the _____________________________ comparison operator to determine whether an object is instantiated from a given instance. a. instanceof b. classof c. objectof d. memberof
a. instanceof
The parameters within the parentheses of a function declaration are what kind of variables? a. local b. global c. unknown d. declared
a. local
Class functions are called _____________________. a. methods b. constructors c. function members d. class members
a. methods
To create an object from a class named Cart that requires two arguments, you code a. new Cart($arg1, $arg2) b. new Cart(arg1, arg2) c. Cart__constructor($arg1, $arg2) d. Cart__constructor(arg1, arg2)
a. new Cart($arg1, $arg2)
Within a function, you can end the function and pass the result back to the calling statement by coding a _________________________________ statement. a. return b. for c. reference d. conditional
a. return
When you declare a global variable with the global keyword, you do not need to assign the variable a(n) ____________________________. a. value b. definition c. function d. name
a. value
You can use the ______________________________ variable within a class to refer to the current object that has been created from the class. a. $that b. $this c. global d. member function
b. $this
To create a class in PHP, use the ________________________ keyword to write a class definition. a. definition b. class c. create d. construct
b. class
A ___________________________________ is a special method within a class that is executed when a new object is created from the class. a. data member b. constructor c. class member d. property
b. constructor
Information contained within variables is called __________________________. a. code b. data c. components d. objects
b. data
Class variables are also known as _______________________________. a. class members b. data members c. classmates d. parameters
b. data members
What will be returned if you use a local variable outside the function in which it is declared? a. value b. error message c. function d. nothing
b. error message
A function is just a _________________________________ that contains one or more functions. a. function b. file c. notation d. class
b. file
Within a function, you can use the ______________________________ keyword if you need to refer to a variable that's declared outside the function. a. local b. global c. local or global d. reference
b. global
A particular instance of an object ___________________________ the methods and properties of its class. a. cancels b. inherits c. creates d. instantiates
b. inherits
A hyphen and a greater-than symbol (->) used to access (or "call") the methods and properties contained in an object are referred to as ___________________________. a. class b. member selection (or, object access modifier) notation c. selector d. data structure
b. member selection (or, object access modifier) notation
Reusable software objects that can be incorporated into multiple programs is called _________________________________. a. object-based programming b. object-oriented programming c. snipets d. functions
b. object-oriented programming
When you use object-oriented techniques to implement the MVC pattern, the methods of the model return the data as either arrays or a. classes b. objects c. properties d. result sets
b. objects
When a new class extends a superclass, it inherits the properties and methods of the superclass. Then, it can _____________________________ by providing your own versions. a. override the inherited properties b. override the inherited methods c. delete any of the inherited properties d. delete any of the inherited methods
b. override the inherited methods
To enable anyone to call a class's member function use a(n) __________________________________. a. private access specifier b. public access specifier c. hidden access specifier d. open access specifier
b. public access specifier
To code a constructor for a class named Cart that requires two arguments, you start with this code: a. public function Cart($arg1, $arg2) { b. public function __construct($arg1, $arg2) { c. private function Cart($arg1, $arg2) { private function __construct($arg1, $arg2) {
b. public function __construct($arg1, $arg2) {
To prevent other classes from directly accessing the properties of a class, you can code them as private. Then, to make them available to other classes, you can code a. private methods to set and get their values b. public methods to set and get their values c. a constructor to set and get their values d. a destructor to set and get their values
b. public methods to set and get their values
When you use a variable in a PHP program, you must be aware of the variable's _______________________________. a. placement b. scope c. function d. statement
b. scope
To call a static method named randomize in a class object named Cart, you code (this operator allows access to static, constant, and overridden properties or methods of a class) a. Cart->randomize() b. Cart$randomize() c. Cart::randomize() d. Cart::$randomize()
c. Cart::randomize()
__________________________ the object means creating an object from a class. a. Editing b. Threading c. Instantiating d. Copying
c. Instantiating
The function that follows returns function coin_toss() { if (mt_rand(0, 1) == 0) { $coin = 'heads'; } else { $coin = 'tails'; } return $coin; } a. a random value between 0 or 1 b. a value of either 0 or 1 c. a value of either "heads" or "tails" d. a reference to the $coin variable
c. a value of either "heads" or "tails"
In PHP, function name duplications are likely to occur because a. namespaces create logical function groups b. all the functions for an application have to be stored in the same file c. all functions have global scope d. most programmers use the same naming conventions for functions
c. all functions have global scope
A _______________________________ defines the methods and properties of an object. a. data member b. constructor c. class d. function
c. class
The _________________________________ function determines whether a class exists and is available to the current script. a. object_exists() b. get_class() c. class_exists() d. member_exists()
c. class_exists()
All of the arguments that are passed to a function are available in an array that can be accessed by using the a. $_ARGUMENTS variable b. $_FUNCTION variable c. func_get_args function d. func_num_args function
c. func_get_args function
To call a function, you code named randomize that has one parameter that has a default value of 5 and one required parameter that's passed by reference, you start the function like this: a. function randomize($&parm1, $parm2 = 5) { b. function randomize($parm1 = 5, $&parm2) { c. function randomize(&$parm1, $parm2 = 5) { d. function randomize($parm1 = 5, &$parm2) {
c. function randomize(&$parm1, $parm2 = 5) {
With many programming languages, global variables are automatically available to all parts of your program, including ________________________________. a. statements b. definitions c. functions d. declarations
c. functions
An object created from an existing class is called a(n) _________________________. a. method b. property c. instance d. variable
c. instance
If you declare a variable within a function, the variable has _____________________________________ scope. a. reference b. global c. local d. both global and local
c. local
By default, all arguments for PHP functions are passed by _____________________________. a. number b. reference c. value d. type
c. value
___________________ are the functions and variable defined in a class. a. Constructors b. Methods c. Function Members d. Class Members
d. Class Members
To call a function, code the function name followed by a set of parentheses that contains a list of the required _____________________________. a. data members b. function c. values d. arguments
d. arguments
A static property or method is one that belongs to a _______________________________, not to an object. a. data member b. access modifier c. function d. class
d. class
Object are organized into ___________________________________. a. programs b. instances c. functions d. classes
d. classes
When you use object-oriented techniques to implement the MVC pattern, the model consists of _____________________________ that contain the required methods. a. global variables b. properties c. methods or functions d. classes
d. classes
Objects in which all code and required data are contained within the object itself are _____________________________. a. instances b. contained c. null d. encapsulated
d. encapsulated
If you create a function with a variable number of parameters, you need to use a special PHP _____________________________ to get an array of the arguments that are passed to the function. a. data member b. class c. variable d. function
d. function
Programming code and data that can be treated as an individual unit or component is known as a(n) _________________________. a. method b. function c. attribute d. object
d. object
To code a method within a class that sets the value for a private property named $name based on the argument that's passed to it, you start with this code: a. public function setName() { b. public function setName($value) { c. private function setName() { d. private function setName($value) {
d. private function setName($value) {