Main Snake Zend Zend Questions Exam Quicktest MZend

1h 30m 00s


Question: 1 (ID:259)

ID: 259


You want to check whether the header has already been sent or not. Which of the following code segments will you use to accomplish the task?





Question: 2 (ID:470)

ID: 470


Given the following code:


                        
Interface Verifiable {
   public function verify();
}

Class Cheque {
   public function verify() {
      return true;
   }
}

Class CurrencyCheque extends Cheque implements Verifiable 
{
    // interesting stuff happens
}

$obj = new CurrencyCheque();                    

What happens when we instantiate a CurrencyCheque object?



Question: 3 (ID:464)

ID: 464


Which of the following is a valid namespace operator in PHP?





Question: 4 (ID:215)

ID: 215


Fill in the blank with the appropriate function name. The _____ function is used to encode a string/array into a json encoded string.





Question: 5 (ID:291)

ID: 291


Fill in the blank with the appropriate function(). The ___ function is used to copy data from one stream to another. It is mainly useful in copying data between two open files. *Matching is case-insensitive.





Question: 6 (ID:22)

ID: 22


Mark works as a Web Developer for Unicorn Inc. He develops an application in PHP using the following code:


                        
switch(1) {
      case 1: print("Book Details"); 
      case 2: print("Book Author"); 
      default: print("Missing Book");
}                    

What will be the output of the script?



Question: 7 (ID:352)

ID: 352


What is the output of the following script?


                        
$number = 25;
if ($number <= 25) {
    echo "lte";
} else if ($number == 25) {
    echo "e";
} else if ($number >= 25) {
    echo "gte";
} else {
    echo "o";
}                    

Enter the exact script output



Question: 8 (ID:650)

ID: 650


Consider the following function:


                        
function redirect($url) {
    // Check to make sure we haven't already sent
    // the header:    
    if(/*?????*/) {
        header("Location: $url");
    }
}                    

What conditional should replace the ????? above?



Question: 9 (ID:628)

ID: 628


Which of the following SQL statements will improve SQLite write performance?





Question: 10 (ID:225)

ID: 225


Consider the following string:


                        
ZeNd php                    

After running a PHP script, the above string is converted in the following format:



Question: 11 (ID:346)

ID: 346


What is the output of the following PHP script?


                        
$myArray = array(1, 2, 3);
for ($i = 0, $length = count($myArray); $i < $length; $i++) {
    echo $myArray[$i];
}                    

Enter the exact script output



Question: 12 (ID:58)

ID: 58


You run the following script:


                        
<?php
function odd() {
    for($i = 1; $i <= 50; $i = $i + 2) {
        echo "$i";
    }
}
echo "The last value of the variable \$i: $i";                    

What will be the output?



Question: 13 (ID:43)

ID: 43


Which of the following files can be used to modify PHP configurations?





Question: 14 (ID:360)

ID: 360


What is the output of the following PHP script.


                        
$int1 = 25;
$int2 = 10;

$int3 = ceil($int1 / $int2);
$int4 = ceil((int) ($int1 / $int2));

echo $int3 . ' - ' . $int4;                    



Question: 15 (ID:96)

ID: 96


You run the following script:


                        
$array1 = array ("a", "b", "c", "d", "e", "f");
$array2 = array_slice($array1, 2, 2);
foreach ( $array2 as $val ) {
    print "$val ";
}                    

What will be the output?



Question: 16 (ID:707)

ID: 707


Which of the following statements about object serialization are true ?





Question: 17 (ID:486)

ID: 486


What does the following code output?


                        
$i = function($j) {
   $i = $j + 4;
   return $i++;
};
$j = 6;
echo $i($j);                    



Question: 18 (ID:367)

ID: 367


What is the output of the following PHP script?


                        
$arr1 = ['a' => 'Apple',  'b' => 'Banana'];
$arr2 = ['b' => 'Banana', 'a' => 'Australia',  'Apple'];
$arr3 = array_diff($arr1, $arr2);
$arr4 = array_diff($arr2, $arr1);
$keys = array_keys($arr4);

echo count($arr3) . ' - ' . $keys[0];                    



Question: 19 (ID:620)

ID: 620


For an arbitrary string $mystring, which of the following checks will correctly determine if the string PHP exists within it?





Question: 20 (ID:40)

ID: 40


Assume that today is January 8th, 2013, 5:16:18 pm in MST time zone.


                        
<?php echo date('l \t\h\e jS');                    



Question: 21 (ID:272)

ID: 272


Which of the following header codes is used for redirection?





Question: 22 (ID:131)

ID: 131


Maria creates an application using PHP script. The application contains certain classes. The class design requires that a particular member variable must be directly accessible to any subclass of this class only. What should Maria do to achieve this?





Question: 23 (ID:192)

ID: 192


Which of the following functions can you use to add data? Each correct answer represents a complete solution. Choose all that apply.





Question: 24 (ID:256)

ID: 256


You want to retrieve all the data from any given table. You also want to ensure that no duplicate values are displayed. Which of the following SQL statements will you use to accomplish the task?





Question: 25 (ID:802)

ID: 802


If a function signature contains three parameters, for which of them may the splat operator be used?





Question: 26 (ID:113)

ID: 113


Which of the following keywords is used to prevent a method/class to be overridden by a subclass?





Question: 27 (ID:648)

ID: 648


Which of the following php.ini directives should be disabled to improve the outward security of your application?





Question: 28 (ID:722)

ID: 722


Considering the table structure below what MySQL query will load a result set containing all students names enrolled in the programming classes ?


                        
--students table:
| studentid | name |
--------------------
| 1 | Mike |
| 2 | John |
| 3 | Jeff |
| 4 | Anne |

--classes table:
| classid | classname 
-------------------------
| 1 | Math
| 2 | Programming
| 3 | Biology

classes_to_students table:
| studentid | classid
-------------------------
| 1 | 1
| 2 | 2
| 3 | 2
| 4 | 3                    



Question: 29 (ID:139)

ID: 139


Which of the following functions will sort an array in ascending order by value, while preserving key associations?





Question: 30 (ID:56)

ID: 56


You run the following PHP script:


                        
$a = 20 % -8;
echo $a;                    



Question: 31 (ID:626)

ID: 626


Setting a HTTP cookie on the client which is not URL-encoded is done how in PHP 5?





Question: 32 (ID:561)

ID: 561


Using flock() to lock a stream is only assured to work under what circumstances?





Question: 33 (ID:135)

ID: 135


Assuming every method call below returns an instance of an object, how can the following be re-written in PHP5/7?


                        
$a = new MyClass();
$b = $a->getInstance();
$c = $b->doSomething();                    



Question: 34 (ID:768)

ID: 768


What is the output of the following code?


                        
class A {
    public function __call($f, $arg){
        return static::who();
    }
    public static function who() { 
        echo __CLASS__;
    }
}
class B extends A {
    public static function who() { 
        echo __CLASS__;
    }
}
$b = new B();
echo $b->test();                    



Question: 35 (ID:255)

ID: 255


You have to select persons whose age is between twenty-five and forty from a database named HumanResource. Which of the following criteria will you use in the query to accomplish the task?





Question: 36 (ID:134)

ID: 134


You want to save a client's session values in a database. Which of the following actions will you take to accomplish this task?





Question: 37 (ID:801)

ID: 801


What is the ouput of the following code?


                        
class Magic {
    public $a = "A";
    protected $b = ["a" => "A", "b" => "B", "c" => "C"];
    protected $c = [1, 2, 3];

    public function __get($v)
    {
        echo "$v,";
        return $this->b[$v];
    }

    public function __set($var, $val)
    {
        echo "$var: $val,";
        return $this->$var = $val;
    }
}

$m = new Magic();
echo $m->a . "," . $m->b . "," . $m->c . ",";
$m->c = "CC";
echo $m->a . "," . $m->b . "," . $m->c;                    



Question: 38 (ID:500)

ID: 500


By default PHP stores its sessions on the web server's filesystem. What function is used to tell PHP to use your custom session storage handler?





Question: 39 (ID:280)

ID: 280


What is the maximum limit of the file size that a user can upload according to the code snippet given below?


                        
<form enctype="multipart/form-data" action="index.php" method="post">
   <input type="hidden" name="MAX_FILE_SIZE" value="5000" />
   <input name="filedata" type="file" />
   <input type="submit" value="Send file" />
</form>                    



Question: 40 (ID:624)

ID: 624


A fingerprint of a string can be determined using which of the following?





Question: 41 (ID:687)

ID: 687


Which of the following functions are part of PHP's internal Iterator interface?





Question: 42 (ID:80)

ID: 80


You run the following PHP script:


                        
$array1 = array("a", "b", "c", "d", "e", "f");
$array2 = array_slice($array1, -3);
 
foreach($array2 as $val) {
    print "$val ";
}                    

What will be the output?



Question: 43 (ID:144)

ID: 144


Which of the following OOP`s design patterns is used to encapsulate a data source so that accessing data source components becomes hidden within the class that implements the pattern?





Question: 44 (ID:453)

ID: 453


What is the output of the following code?


                        
$a = 42 & 05 + 17;
echo $a;                    



Question: 45 (ID:219)

ID: 219


What will be the output of the following PHP code?


                        
$a = "hi,world";
$b = array_map("strtoupper", explode(",", $a));
foreach($b as $value) {
    print "$value";
}                    



Question: 46 (ID:186)

ID: 186


Which of the following is used to retrieve the root element from an XML file?





Question: 47 (ID:516)

ID: 516


Consider the following code snippet:


                        
$query = "INSERT INTO mytable (myinteger, mydouble, myblob, myvarchar)
              VALUES (?, ?, ?, ?)";
$statement = mysqli_prepare($link, $query);
if (!$statement) {
        die(mysqli_error($link));
}
 /* The variables being bound to by MySQLi don't need to exist prior to binding */
 mysqli_bind_param($statement, "idbs", $myinteger, $mydouble, $myblob, $myvarchar);
 /* ???????????? */   
/* execute the query, using the variables as defined. */
if (!mysqli_execute($statement)) {
        die(mysqli_error($link));
}                    

Assuming this snippet is a smaller part of a correctly written script, what actions must occur in place of the ????? in the above code snippet to insert a row with the following values: 10, 20.2, foo, string ?



Question: 48 (ID:751)

ID: 751


Consider the following snippet of code. What is the name of the function that needs to be inserted in the placeholder?


                        
$dh = opendir(".");
while ($file = _____($dh)) {
    echo $file;
}                    



Question: 49 (ID:311)

ID: 311


Which of the statements below best describe the following PHP code. Note that backticks are being used (not single quotes).


                        
$output = `ls`;                    



Question: 50 (ID:763)

ID: 763


Which of the following cannot be a part of the class definition?





Question: 51 (ID:736)

ID: 736


Which PHP functions may be used to find out whitch PHP extension are available in the system? (Choose 2)





Question: 52 (ID:374)

ID: 374


What is the output of the following PHP code?


                        
$myArray = [0, NULL, '', '0', -1];
echo count(array_filter($myArray));                    



Question: 53 (ID:656)

ID: 656


Creating new nodes in XML documents using PHP can be done using which XML/PHP 5 technologies?





Question: 54 (ID:775)

ID: 775


What are the main advantages of replacing many fatal errors with Exceptions in PHP 7?





Question: 55 (ID:359)

ID: 359


This question tests your knowledge of boolean values and casting. What is the output of the following PHP script.


                        
$myInt = -1;
$myBool = (bool) $myInt;
if ($myBool > 0) {
    echo "5";
} else if ($myBool == true) {
    echo "6";
} else if (!$myBool) {
    echo "7";
} else {
    echo sprintf("%d", $myBool);
}                    

Enter the exact script output



Question: 56 (ID:423)

ID: 423


What is the output of the following PHP script?


                        
$a = 0.5;
$b = 0.1;
$c = 16;
echo sprintf('%01.2lf %.1lf 0x%x', $a, $b, $c);                    



Question: 57 (ID:499)

ID: 499


What is the preferred way of writing the value 25 to a session variable called age?





Question: 58 (ID:120)

ID: 120


Which of the following are the uses of Reflection? Each correct answer represents a complete solution. Choose all that apply.





Question: 59 (ID:437)

ID: 437


What would you expect to get from PDOStatement::fetch() in its default mode?





Question: 60 (ID:410)

ID: 410


The parse_str() function is used to parse a query string just as if it were passed in the URL of a HTTP request. If the second argument is included then the parsed values are written to this variable. What is the output of the following script?


                        
$str = "days=Mon&days=Wed" . "&fruit[1]=Apple&fruit[]=Banana&age=13";
parse_str($str, $output);
// gettype will return 'array' or 'string'
echo gettype($output['days']);
echo ' - ';
// array_search will return the key
// where the first argument is located
echo array_search('Banana', $output['fruit']);
echo ' - ';
echo array_key_exists('age', $output) ? $output['age'] : 0;                    

Enter the exact script output



Question: 61 (ID:171)

ID: 171


Which of the following functions wraps a string to a given number of characters?





Question: 62 (ID:371)

ID: 371


Consider the following PHP code:


                        
$myArray = [10, 20, 30, 40];                    

What is the simplest way to return the values 20 and 30 in a new array without modifying $myArray?



Question: 63 (ID:631)

ID: 631


Consider the following simple PHP script:


                        
$dom = new DomDocument();
$dom->load('test.xml');
$xpath = new DomXPath($dom);
$nodes = $xpath->query(???????, $dom->documentElement);
echo $nodes->item(0)->getAttributeNode('bgcolor')->value . "\n";                    

What XPath query should go in the ?????? above to display the "bgcolor" attribute of the first "body" node in the XML document?



Question: 64 (ID:430)

ID: 430


What is the output of the following:


                        
$m = 3;
$n = 0;
function l() {
   $m = 0;
   $m++;
   global $n;
   return array($n,$m);
}
echo implode((L(l())),',');                    



Question: 65 (ID:265)

ID: 265


Which of the following HTML code snippets can be used for the file uploading?





Question: 66 (ID:95)

ID: 95


What will be the output of the following code snippet?


                        
$input = [4, "4", "3", 4, 3, "3", 3, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7];
echo count(array_unique($input));                    



Question: 67 (ID:251)

ID: 251


Martin works as a Database Administrator for MTech Inc. He designs a database that has a table named Products. He wants to create a report listing different product categories. He does not want to display any duplicate row in the report. Which of the following SELECT statements will Martin use to create the report?





Question: 68 (ID:728)

ID: 728


Is there a way to make E_NOTICE type errors behave like fatal errors in PHP and therefor stop script execution when such an error occurs ?





Question: 69 (ID:717)

ID: 717


Which PHP function(s) can be used to check if a variable is defined and is not NULL ?





Question: 70 (ID:231)

ID: 231


What will be the output of the following PHP code snippet?


                        
echo <<<"FOOBAR"
Hello World!
FOOBAR;                    



Question: 71 (ID:427)

ID: 427


One way to format currencies in PHP is to use the built-in money_format() function. Before using it you must set the locale for the type of currency you're trying to format. What is the output of the following PHP script? The currency name for en_US is USD and uses $ as the currency symbol. Additionally, there are 100 cents to the dollar.


                        
setlocale(LC_MONETARY, 'en_US');
$amt = 100;
echo money_format('%.2n', $amt);                    



Question: 72 (ID:698)

ID: 698


Considering the code below


                        
class AppException extends Exception {
  function __toString() {
    return "Your code has just thrown an exception: {$this->message}\n";
  }
}

class Students {
  public $first_name;
  public $last_name;

  public function __construct($first_name, $last_name) {
    if(empty($first_name)) {
      throw new AppException('First Name is required', 1);
    }

    if(empty($last_name)) {
      throw new AppException('Last Name is required', 2);
    }
  }
}

try {
    new Students('', ''); 
} catch (Exception $e) {
    echo $e;
}                    

Which of these statements are correct ?



Question: 73 (ID:289)

ID: 289


Which of the following file permissions is set by the tempnam() function for the newly created temp file?





Question: 74 (ID:357)

ID: 357


What is the function used to define a custom error handling function?





Question: 75 (ID:574)

ID: 574


Which of the following list of potential data sources should be considered trusted?