Sail E0 Webinar

MCQs

Total Questions : 53 | Page 5 of 6 pages
Question 41. Array values are keyed by ______ values (called indexed arrays) or using ______ values (called associative arrays). Of course, these key methods can be combined as well.
  1.    Float, string
  2.    Positive number, negative number
  3.    Integer, string
  4.    Even number, string
  5.    String, Boolean
 Discuss Question
Answer: Option C. -> Integer, string
Question 42. What will the following script output?$array = array (1, 2, 3, 5, 8, 13, 21, 34, 55);$sum = 0;for ($i = 0; $i < 5; $i++) {$sum += $array[$array[$i]];}echo $sum;
  1.    78
  2.    5
  3.    NULL
  4.    19
 Discuss Question
Answer: Option A. -> 78
Question 43. What will be the output of the following PHP code?$number = array ("4", "hello", 2);echo (array_sum ($number));
  1.    6
  2.    4
  3.    2
  4.    4hello2
 Discuss Question
Answer: Option A. -> 6
Question 44. What will be the output of the following PHP code?$fruits = array ("apple", "mango", "peach", "pear", "orange");$subset = array_splice ($fruits, 2);print_r ($fruits);
  1.    Array ( [0] => pear [1] => orange )
  2.    Error
  3.    Array ( [0] => apple [1] => mango [2] => peach )
  4.    Array ( [0] => apple [1] => mango )
 Discuss Question
Answer: Option D. -> Array ( [0] => apple [1] => mango )
Question 45. What will be the output of the following PHP code?$array1 = array ("KA", "LA", "CA", "MA", "TA");$array2 = array ("KA", "IA", "CA", "GA", "TA");$inter = array_intersect ($array1, $array2);print_r ($inter);
  1.    Array ( [0] => KA [2] => CA [4] => TA )
  2.    Array ( [0] => KA [1] => LA [2] => CA [3] => MA [4] => TA [5] => IA [6] => GA )
  3.    Array ( [1] => LA [3] => MA )
  4.    Array ( [1] => IA [3] => GA )
 Discuss Question
Answer: Option A. -> Array ( [0] => KA [2] => CA [4] => TA )
Question 46. Absent any actual need for choosing one method over the other, does passing arrays by value to a read-only function reduce performance compared to passing them by reference?
  1.    Yes, but only if the array is large.
  2.    Yes, because the interpreter must always create a copy of the array before passing it to the function.
  3.    No
  4.    Yes, but only if the function modifies the contents of the array.
  5.    Yes, because PHP must monitor the execution of the function to determine if changes are made to the array.
 Discuss Question
Answer: Option C. -> No
Question 47. Assume you would like to sort an array in ascending order by value while preserving key associations. Which of the following PHP sorting functions would you use?
  1.    sort()
  2.    ksort()
  3.    asort()
  4.    usort()
  5.    krsort()
 Discuss Question
Answer: Option C. -> asort()
Question 48. There are three different kind of arrays:
  1.    Numeric array, String array, Multidimensional array
  2.    Const array, Associative array, Multidimensional array
  3.    Numeric array, Associative array, Multidimensional array
  4.    Numeric array, Associative array, Dimensional array
 Discuss Question
Answer: Option C. -> Numeric array, Associative array, Multidimensional array
Question 49. Which array function checks if the specified key exists in the array?
  1.    arrays_key_exists()
  2.    array_key_exists()
  3.    array_key_exist()
  4.    array_keys_exists()
 Discuss Question
Answer: Option B. -> array_key_exists()
Question 50. What elements will the following script output?$array = array (true => 'a', 1 => 'b');var_dump ($array);
  1.    None
  2.    True => 'a', 1 => 'b'
  3.    1 => 'b'
  4.    It will output NULL
 Discuss Question
Answer: Option D. -> It will output NULL

Latest Videos

Latest Test Papers