click below
click below
Normal Size Small Size show me how
M3 - AppDev
FA3(20/20)APPLICATION DEVELOPMENT AND EMERGING TECHNOLOGIES/CCS0043
| Question | Answer |
|---|---|
| ______________________________________________________________________ | (2 wrong) |
| $mo = array(“jan”,”feb”,”mar”); echo “<pre>”; var_dump ($mo); echo “</pre>”; Check the code if valid or invalid? | Valid |
| Function can have a return value | True |
| Using foreach statement you can display both the keys and value of each element in the array. | True |
| Global Variables is declared inside a function and is only available within the function in which it is declared. | False |
| Syntax of a function | Function name(param){} |
| Local Variables is one that declared outside a function and is available to all parts of the program. | False |
| function a($a,$b){ return $a+$b; } echo a(5,4); what is the name of the parameter? | $a and $b - should be correct but is wrong; try a |
| functions that are built-in into PHP to perform some standard operations | Predefined functions |
| You can create a function inside of a function | True |
| Sorts by key | ksort($array) |
| is a group of PHP statements that performs a specific task. Functions are designed to allow you to reuse the same code in different locations. | Functions |
| You can pass values to a function and you can ask functions to return a value. | True |
| Sorts by value; keeps the same key | asort($array) |
| foreach($arr as ___ => $value){ //do something } | $key |
| Sorts by value in reverse order; keeps the same key | arsort($array) |
| ksort() and krsort() used to sort elements by values. | False(Sorted by keys) |
| function is used to print the array structure. | print_r |
| functions are commonly used for debugging. The point of this of these functions is to help you visualize what’s going on with compound data structures like arrays. | print_r() and var_dump() |
| We use static keyword to declare a variable inside a function that will act as accumulator variable this will let the program remember the last value of the variable that was used. | True |
| foreach($arr as ______) | $value |
| _______________________________________________________________________ | (1 wrong) |
| function a($a,$b){ return $a+$b; } echo a(6,5); what is the value of $a? | 6 |
| Array index in PHP can be also called | Array keys |
| Array index in PHP can be also called as array storage | False |
| Array can be used as ordinary array same as in C and C++ arrays. | True |
| Functions can only have 1 parameter | False |
| $fruit = array(“orange”,”apple”,”grape”,”banana”); What is the value of index 1? | apple |
| references a corresponding value. | Array index |
| $g = 200; function a(){echo “5”;} function b(){echo “4”;} ab(); what is the output of the code? | error |
| Array can be used as ordinary array same as in | C and C++ |
| What do you call a function inside of a function | Nested function |
| $g = 200; function a(){echo “5”;} function b(){echo “4”;} a(); what is the output of the code? | 5 |
| $fruit = array(“orange”,”apple”,”grape”,”banana”); What is the value of index 0? | orange |
| Function count($val){ static $c = 0; $c += $val; echo $c; } Count(4); Count(3); What is the output of the code? | Error |
| $s = “variable”; function f(){ global $s; echo “function called ”; echo “$s”; } f(); what is the output of the code? | function called variable |
| The foreach statement is use to iterate through the element in an array. | True |
| var_dump function is same as print_r function except it adds additional information about the data of each element. | True |
| _______________________________________________________________________ | (2 wrong) |
| $g = 200; function a(){echo “5”;} function b(){echo “4”;} a();b(); what is the output of the code? | 54 |
| Each member of the array index references a corresponding value and can be a simple numerical reference to the value’s position in the series, or it could have some direct correlation to the value. | True |
| A function that is declared inside a function is said to be hidden. | False(Nested function) |
| $f = array( '102' => "red", '101' => "blue", '100' => "yellow"); ksort($f); print_r($f); What is the key of the yellow? | 100 |
| $f = array( '102' => "red", '101' => "blue", '100' => "yellow"); krsort($f); print_r($f); What is the output of the code? | Array ( [102] => red [101] => blue [100] => yellow ) |
| Function count($val){ $c = 0; $c += $val; echo $c; } count(10); count(5); What is the output of the code? | Error |
| $fruit = array(“orange”,”apple”,”grape”,”banana”); What is the value of index 2? | grape |
| function keyword is used in PHP to declare a function. | True |
| $num=array(1,2,3,4,5); foreach($num as $val){ echo $val; } What is the output of the code? | 12345 |
| is used to retain the values calls to the same function. | Static variables |
| You can create your own function inside of a php code | True |
| To gain access to a variable that is outside from the function we use the global keyword. | True |
| foreach($arr as ___ => $value){ //do something } | $key |
| _______________________________________________________________________ | |
| functions that are provided by the user of the program. | User defined function |
| is declared inside a function and is only available within the function in which it is declared. | Local variables |
| function disp(){ function disp2(){ echo “hello”; } } disp(); disp2(); | hello |
| You use can functions in different ways. | True |
| Sorts by a function | usort($array) |
| This takes an argument of any type and prints it out, which includes printing all its parts recursively. | print_r() |
| function disp(){ function disp2(){ echo “hello”; } } disp(); disp2(); | hello |
| Array is used to aggregate a series of similar items together. | True |
| param – is the formal parameters of the function. Parameter must follow the rule of naming dentifier. | True |
| Syntax for foreach | foreach($arr as $value){} |
| Id the keyword used to declare a function | function |
| _______________________________________________________________________ | |
| $f = array( '102' => "red", '101' => "blue", '100' => "yellow"); krsort($f); print_r($f); What is the output of the code? | Array ( [102] => red [101] => blue [100] => yellow ) |
| $t = 100; function one(){ echo “1000”; } one(); what is the value of the $t after execute the code? | 100 |
| Functions can be user defined generally defined by the user of the program and predefined that are build in using libraries. | True |
| function a($a,$b){ return $a+$b; } echo a(5,4); what is the output of the code? | 9 |
| is used to aggregate a series of similar items together, arranging and dereferencing them in some specific way. | Array |
| $t = 100; function one(){ echo “value”; } one(); what is the function name inside of the code? | one |
| foreach(____ as $value) | $arr |
| Sorts by value in reverse order; assign new number as the keys | rsort($array) |
| $g = 200; function a(){echo “5”;} function b(){echo “4”;} a(); what is the value of the $g? | 200 |
| $s = “variable”; function f(){ echo “function called ”; echo “$s”; } f(); what is the output of the code? | function called undefined variable: s |
| asort() and arsort() used to sort elements by keys. | False(Sorted by values) |
| _______________________________________________________________________ | (1 wrong) |
| You can use only 10 for Array elements | False |
| specify an array expression within a set of parenthesis following the foreach keyword. | True |
| $fruit = array(“orange”,”apple”,”grape”,”banana”); What is the value of index 3? | banana |
| Sorts by key in reverse order | krsort($array) |
| is a statement used to iterate or loop through the element in an array. | foreach() |
| Function can only do something without passing values. | True |
| $a[]=”mango”; $a[]=”apple”; $a[]=”banana”; Check the code if valid or invalid? | Valid |
| _______________________________________________________________________ | (2 wrong) wtf???? |
| sort() and rsort() does not maintain its index reference for each values. | True |
| What is the keyword use to gain access a variable that is outside of the function? | Global |
| function disp(){ function disp2(){ echo “hello”; } } Disp(); disp2(); | error |
| Function can be put anywhere of the code | True |
| sort(), asort(), and ksort() functions are used to sort elements in the array in ascending order. | True |
| Functions are limited to 1 per code only | False |
| _______________________________________________________________________ | |
| PHP array does need to declare how many elements that the array variable have. | False |
| PHP has a built-in function to perform operations | True |
| $g = 200; function a(){echo “5”;} function b(){echo “4”;} b(); what is the output of the code? | 4 |
| $mo = array(“jan”,”feb”,”mar”); echo “<pre>”; print_r ($mo); echo “</pre>”; Check the code if valid or invalid? | Valid |
| _______________________________________________________________________ | |
| Sorts by value; assign new numbers as the keys | sort($array) |
| Functions is a group of PHP statements that performs a specific task. | True |
| _______________________________________________________________________ | |
| asort(), ksort(), arsort(), and krsort() maintains its reference for each values. | True |
| function disp(){ function disp2(){ echo “hello”; } } disp2(); | error |
| it is required to create a function name for a function | True |
| Array index is also known as Array Keys. | True |
| rsort(), arsort(), and krsort() functions are used to sort elements in the array in descending order. | True |