Skip to main content

Arrays — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Arrays — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

PHP’s numerically indexed array begin with position ______.

Question 2 of 40
★ FPSC ★ PPSC

Which of the following are correct ways of creating an array? 1. state[0] = “karnataka”; 2. $state[] = array(“karnataka”); 3. $state[0] = “karnataka”; 4. $state = array(“karnataka”);

Question 3 of 40
★ FPSC ★ PPSC

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

Question 4 of 40
★ FPSC ★ PPSC

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

Question 5 of 40
★ FPSC ★ PPSC

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

Question 6 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $state = array ( "Karnataka" , "Goa" , "Tamil Nadu" , "Andhra Pradesh" ) ; echo (array_search ( "Tamil Nadu" , $state ) ) ; ?>

Question 7 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $fruits = array ( "apple" , "orange" , "banana" ) ; echo (next( $fruits )) ; echo (next( $fruits )) ; ?>

Question 8 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $fruits = array ( "apple" , "orange", array ( "pear" , "mango" ) , "banana" ) ; echo (count( $fruits, 1 )) ; ?>

Question 9 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $cars = array( "Volvo" , "BMW" , "Toyota" ) ; echo "I like " . $cars [ 2 ] . ", " . $cars [ 1 ] . " and " . $cars [ 0 ] . "." ; ?>

Question 10 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $fname = array( "Peter" , "Ben" , "Joe" ) ; $age = array( "35" , "37" , "43" ) ; $c = array_combine( $age, $fname ) ; print_r( $c ) ; ?>

Question 11 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $a =array( "A" , "Cat" , "Dog" , "A" , "Dog" ) ; $b =array( "A" , "A" , "Cat" , "A" , "Tiger" ) ; $c =array_combine( $a,$b ) ; print_r(array_count_values( $c )) ; ?>

Question 12 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $a1 = array ( "a" => "red" , "b" => "green" , "c" => "blue" , "d" => "yellow" ) ; $a2 = array ( "e" => "red" , "f" => "green" , "g" => "blue" , "h" => "orange" ) ; $a3 = array ( "i" => "orange" ) ; $a4 = array_combine ( $a2, $a3 ) ; $result = array_diff ( $a4, $a2 ) ; print_r ( $result ) ; ?>

Question 13 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $a1 = array( "red" , "green" ) ; $a2 = array( "blue" , "yellow" ) ; $a3 = array_merge( $a1, $a2 ) ; $a4 = array( "a" , "b" , "c" , "d" ) ; $a = array_combine( $a4, $a3 ) ; print_r( $a ) ; ?>

Question 14 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $names = array( "Sam", "Bob" , "Jack" ) ; echo $names [ 0 ] . "is the brother of " . $names [ 1 ] . " and " . $names [ 1 ] . "." ; ?>

Question 15 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $names = array( "Sam" , "Bob" , "Jack" ) ; echo $names [ 0 ] . "is the brother of " . $names [ 1 ] . " and " . $names [ 1 ] . "." . $brother; ?>

Question 16 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $place = array( "NYC" , "LA" , "Paris" ) ; array_pop( $place ) ; $place1 = array( "Paris" ) ; $place = array_merge( $place, $place1 ) ; print_r( $place ) ; ?>

Question 17 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $age = array ( "Harry" => "21" , "Ron" => "23" , "Malfoy" => "21" ); array_change_key_case ( $age, CASE_UPPER ); array_pop ( $age ); print_r ( $age ); ?>

Question 18 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $a1 = array ( "a" => "red" , "b" => "green" , "c" => "blue" , "d" => "yellow" ); $result = array_flip ( $a1 ); print_r ( $result ); ?>

Question 19 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $a1 = array ( "a" => "red" , "b" => "green" , "c" => "blue" , "d" => "yellow" ); $a2 = array ("e" => "red" , "f" => "green" , "g" => "blue" ); $result = array_intersect ( $a1, $a2 ); print_r ( $result ); ?>

Question 20 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $a = array( 12 , 5 , 2 ) ; echo( array_product ( $a )) ; ?>

Question 21 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $a = array( "a" => "Jaguar" , "b" => "Land Rover" , "c" => "Audi" , "d" => "Maseratti" ) ; echo array_search( "Audi" , $a ) ; ?>

Question 22 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $city_west = array( "NYC" , "London" ) ; $city_east = array( "Mumbai" , "Beijing" ) ; print_r( array_replace ( $city_west, $city_east )) ; ?>

Question 23 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $people = array( "Peter" , "Susan" , "Edmund" , "Lucy" ) ; echo pos( $people ) ; ?>

Question 24 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $number = range( 0 , 5 ) ; print_r ( $number ) ; ?>

Question 25 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $array = array( "red" , "green" ) ; array_push( $array, "blue" , "yellow" ) ; print_r( $array ) ; ?>

Question 26 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $cars = array( "Volvo" , "BMW" , "Toyota" , "Honda" , "Mercedes" , "Opel " ) ; print_r(array_chunk( $cars, 2 )) ; ?>

Question 27 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $fname = array( "Peter" , "Ben" , "Joe" ) ; $age = array( "35" , "37" , "43" ) ; $c = array_combine( $fname, $age ) ; print_r( $c ) ; ?>

Question 28 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $a = array( "A" , "Cat" , "Dog" , "A" , "Dog" ) ; print_r(array_count_values( $a )) ; ?>

Question 29 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $a1 = array( "a" => "red" , "b" => "green" , "c" => "blue" , "d" => "yellow" ) ; $a2 = array( "e" => "red" , "f" => "green" , "g" => "blue" ) ; $result = array_diff( $a1, $a2 ) ; print_r( $result ) ; ?>

Question 30 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $a1 = array( "red" , "green" ) ; $a2 = array( "blue" , "yellow" ) ; print_r(array_merge( $a1, $a2 )) ; ?>

Question 31 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $a = array( "a" => "red" , "b" => "green" , "c" => "blue" ) ; echo array_shift( $a ) ; print_r ( $a ) ; ?>

Question 32 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $a = array( "red" , "green" , "blue" ) ; array_pop( $a ) ; print_r( $a ) ; ?>

Question 33 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $fruits = array ( "mango" , "apple" , "pear" , "peach" ) ; $fruits = array_flip( $fruits ) ; echo ( $fruits [ 0 ]) ; ?>

Question 34 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $fruits = array ( "mango" , "apple" , "peach" , "pear" ) ; $fruits = asort ( $fruits ) ; printr ( $fruits ) ; ?>

Question 35 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $arr = array ( "picture1.JPG" , "picture2.jpg" , "Picture10.jpg" , "picture20.jpg" ) ; sort( $arr ) ; print_r( $arr ) ; ?>

Question 36 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $face = array ( "A" , "J" , "Q" , "K" ) ; $number = array ( "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "10" ) ; $cards = array_merge ( $face, $number ) ; print_r ( $cards ) ; ?>

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $fruits = array ( "apple" , "mango" , "peach" , "pear" , "orange" ) ; $subset = array_slice ( $fruits, 2 ) ; print_r ( $subset ) ; ?>

Question 38 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $fruits = array ( "apple" , "mango" , "peach" , "pear" , "orange" ) ; $subset = array_splice ( $fruits, 2 ) ; print_r ( $fruits ) ; ?>

Question 39 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $number = array ( "4" , "hello" , 2 ) ; echo (array_sum ( $number )) ; ?>

Question 40 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $array1 = array ( "KA" , "LA" , "CA" , "MA" , "TA" ) ; $array2 = array ( "KA" , "IA" , "CA" , "GA" , "TA" ) ; $inter = array_intersect ( $array1, $array2 ) ; print_r ( $inter ) ; ?>

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →