Computer

Arrays MCQs

Practice Arrays MCQs for competitive exams.

Arrays MCQs

Practice questions from this topic.

What array will you get if you convert an object to an array?

  1. A. An array with properties of that object as the array's elements
  2. B. An array with properties of that array as the object's elements
  3. C. An array with properties of that object as the Key elements
  4. D. An array with keys of that object as the array's elements
Report Error

What functions count elements in an array? 1. count 2. Sizeof 3. Array_Count 4. Count_array

  1. A. Option 2 and 4
  2. B. Option 1 and 2
  3. C. Option 3 and 4
  4. D. Option 1 and 4
Report Error

What function computes the difference of arrays?

  1. A. array_diff
  2. B. diff_array
  3. C. arrays_diff
  4. D. diff_arrays
Report Error

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. A. ksort()
  2. B. asort()
  3. C. krsort()
  4. D. sort() E. usort()
Report Error

There are three different kind of arrays:

  1. A. Numeric array, String array, Multidimensional array
  2. B. Numeric array, Associative array, Dimensional array
  3. C. Numeric array, Associative array, Multidimensional array
  4. D. Const array, Associative array, Multidimensional array
Report Error

Which array function checks if the specified key exists in the array?

  1. A. array_key_exist()
  2. B. array_key_exists()
  3. C. array_keys_exists()
  4. D. arrays_key_exists()
Report Error

What will the following script output? <?php $array = array (1, 2, 3, 5, 8, 13, 21, 34, 55); $sum = 0; for ($i = 0; $i

  1. A. 78
  2. B. 19
  3. C. NULL
  4. D. 5
Report Error

Which function returns an array consisting of associative key/value pairs?

  1. A. count()
  2. B. array_count()
  3. C. array_count_values()
  4. D. count_values()
Report Error

Which function can be used to move the pointer to the previous array position?

  1. A. last()
  2. B. before()
  3. C. prev()
  4. D. previous()
Report Error

Which in-built function will add a value to the end of an array?

  1. A. array_unshift()
  2. B. into_array()
  3. C. inend_array()
  4. D. array_push()
Report Error

Which function will return true if a variable is an array or false if it is not?

  1. A. this_array()
  2. B. is_array()
  3. C. do_array()
  4. D. in_array()
Report Error

What will be the output of the following php code? array( "population" => "11,35,000" , "captial" => "Bangalore" ) , "Tamil Nadu" => array( "population" => "17,90,000" , "captial" => "Chennai" ) ) ; echo $states [ "karnataka" ][ "population" ] ; ?>

  1. A. karnataka 11,35,000
  2. B. 11,35,000
  3. C. population 11,35,000
  4. D. karnataka population
Report Error