test - php5

16
Question: You need to count the number of parameters given in the URL by a POST operation. The correct way Is: a. count($POST_VARS); b. count($POST_VARS_PARAM); c. count($_POST); d. count($HTTP_POST_PARAM); Question: What is the output of the following code? <?php $a = 3; $b = 2; echo (int)$a / (int)$b ?> a. 1 b. 1.5 c. 2 d. 3 e. Error Question: What is the output of the following code? <?php function vec_add (&$a, $b) { $a['x'] += $b['x']; $a['y'] += $b['y']; $a['z'] += $b['z']; } $a = array (x => 3, y => 2, z => 5); $b = array (x => 9, y => 3, z => -7); vec_add (&$a, $b); print_r ($a); ?>

Upload: prince-haldar

Post on 30-Aug-2014

449 views

Category:

Documents


13 download

TRANSCRIPT

Page 1: test - php5

 Question:You need to count the number of parameters given in the URL by a POST operation. The correct way Is:

a. count($POST_VARS);

b. count($POST_VARS_PARAM);

c. count($_POST);

d. count($HTTP_POST_PARAM);

Question:What is the output of the following code?

<?php$a = 3;$b = 2;echo (int)$a / (int)$b?>

a. 1

b. 1.5

c. 2

d. 3

e. Error

Question:What is the output of the following code?

<?php

functionvec_add (&$a, $b){    $a['x'] += $b['x'];    $a['y'] += $b['y'];    $a['z'] += $b['z'];}

$a = array (x => 3, y => 2, z => 5);$b = array (x => 9, y => 3, z => -7);

vec_add (&$a, $b);

print_r ($a);

?>

a. Array(    [x] => 9    [y] => 3    [z] => -7)

b. Array(

Page 2: test - php5

    [x] => 3    [y] => 2    [z] => 5)

c. Array(    [x] => 12    [y] => 5    [z] => -2)

d. Error

e. None of the above

Question:What will be the ouput of the following code?

<?phpfor ($i = 0; $i < 5; ++$i){    if ($i == 2)        continue    print "$i\n";}?>

a. 012345

b. 0134

c. 2

d. 0124

e. None of the above

Question:How would you store order number (34) in an 'OrderCookie'?

a. setcookie("OrderCookie",34);

b. makeCookie("OrderCookie",34);

c. Cookie("OrderCookie",34);

d. OrderCookie(34);

Question:Which of the following is not true for a persistent connection?

a. These are not closed even after the execution of the script

Page 3: test - php5

b. These are mainly used to increase the efficiency of the system

c. These can't be converted to non-persistent connections

d. These are preferably not used in the scripts involving transactions

Question:Which of the following built-in functions assist in checking if the actually function exists or not?

a. exists

b. function_exists

c. fexists

d. isFunction

Question:Which of the following is a correct declaration?

a. static $varb = array(1,'val',3);

b. static $varb = 1+(2*90);

c. static $varb = sqrt(81);

d. static $varb = new Object;

Question:The value of a local variable of a function has to be retained over multiple calls to that function. How should that variable be declared?

a. local

b. global

c. static

d. None of the above

Question:What will be the output of the following code?

     echo 12 . 6;

a. 12 . 6

b. 126

c. 12.6

d. Error: You cannot add integers through the concatenation operator(.)

Question:For passing a variable by reference:

a. Append a "&" prefix

b. Append a "#" prefix

c. Append a "&" suffix

Page 4: test - php5

d. Append a "#" suffix

Question:What will be the output of the following code?

$Rent = 250;function Expenses($Other){   $Rent = 250 + $Other;   return $Rent;}Expenses(50);echo $Rent;

a. 300

b. 250

c. 200

d. Program will not compile

Question:The following php variables are declared:

<?php$company = 'ABS Ltd';$$company = ', Sydney';?>  

Which of the following is not a correct way of printing 'ABS Ltd, Sydney?'

a. echo "$company $$company";

b. echo "$company ${$company}";

c. echo "$company ${'ABS Ltd'}";

d. echo "$company {$$company}";

Question:Which of the following are 'magic constants'?

a. __LINE__

b. __FILE__

c. __PRETTY_FUNCTION__

d. __CLASS__

e. __METHOD__

Question:State whether True or False

Paamayim Nekudotayim operator allows access only to the static members of a class?

a. True

Page 5: test - php5

b. False

Question:You have designed a user login form as follows:

<form action="Validate.php" method="post">    User Name:  <input type="text" name="username" /><br />    Password: <input type="password" name="password" /><br />    <input type="submit" name="login" value="Login" /></form>

How can you access the username entered by the user in the 'Validate.php' webpage?

a. $var= $_POST['username'];

b. $var= $_REQUEST['username'];

c. import_request_variables('p', 'p_');$var= $p_username;

d. All of the above

Question:What will be the output of the following code?

function fn(&$var){   $var = $var - ($var/10 * 5);   return $var;}echo fn(100);

a. 100

b. 50

c. 98

d. Error message

e. None of the above

Question:Which one is correct?

a. $s=fwrite("a string here");

b. $s=fwrite($fp,"a string here");

c. $s=fwrite("a string here",$fp);

d. none of the above

Question:Which of the following is not a valid PHP parser tag?

a. script

b. ?p

c. %

Page 6: test - php5

d. ?php

Question:Which of the following statement is not correct for PHP?

a. It is a server side scripting language

b. A php file may contain text, html tags or scripts

c. It can run on windows and Linux systems only

d. It is compatible with most of the common servers used today

Question:Which of the following text manipulation functions is not supported by PHP?

a. strtoupper()

b. ucfirst()

c. strtolower()

d. strsplit()

Question:How would you start a session?

a. session(start);

b. session();

c. session_start();

d. begin_sesion();

Question:Which of the following is not supported in PHP5?

a. Type Hinting

b. Reflection

c. Magic Methods

d. Multiple Inheritance

e. Object Cloning

Question:Which of the following variable is supported by 'str_replace()' function?

a. Integer

b. String

c. Boolean

d. Array

Question:Which of the following statements is incorrect with regard to interfaces?

Page 7: test - php5

a. A class can implement multiple interfaces

b. An abstract class cannot implement multiple interfaces

c. An interface can extend multiple interfaces

d. Methods with same name, arguments, and sequence can exist in the different interfaces implemented by a class

Question:What will be the output of the following script?

<?php $count=50;function Argument(){$count++;echo $count;}Argument();?>

a. It will print 50

b. It will print 51

c. It will print 52

d. It will print 1

Question:Which of the following functions output text?

a. echo()

b. print()

c. println()

d. display()

Question:Which of the following is correct with regard to echo and print ?

a. echo is a construct and print is a function

b. echo is a function and print is a construct

c. Both are functions

d. Both are constructs

Question:Which of the following is a not a correct way of commenting in php?

a. //PHP Comment

b. /*PHP Comment*/

c. #PHP Comment

Page 8: test - php5

d. /#PHP Comment

Question:The default value of register_globals in PHP is:

a. Off

b. On

Question:What is the result of the following expression?

5+2 * 4+6

a. 70

b. 19

c. 34

d. 21

Question:Which composite data types are supported by php?

a. Array

b. Enumeration

c. List

d. Object

e. Integer

Question:Which of the following statements is true with regard to comparisons in PHP5?

a. With "= =" operator, two object instances are equal if they have the same attributes and values, and are instances of a different class.

b. With "= =" operator two object instances are equal if they have the same attributes and values, and are instances of the same class.

c. With (===) operator, object variables are identical if and only if they refer to the same instance of the same class.

d. With (===) operator, object variables are identical if and only if they refer to the different instance of the same class.<

Question:Which of the following is not a file related function in PHP?

a. fclose

b. fopen

c. fwrite

d. fgets

Page 9: test - php5

e. fappend

Question:Variable functions in PHP don't work directly with:

a. echo()

b. isset()

c. print()

d. All of the above

Question:What will be the output of following code?

$a = 10;echo "Value of a = $a";

a. Value of a = 10

b. Value of a = $a

c. Undefined

d. Syntax Error

Question:For the following code:

<?php echo 30 * 5.7; ?>

the output will be:

a. 171

b. Expressions can't be used with echo statements

c. 150.7

d. 30 * 5.7

Question:Which of the following crypto in PHP returns longest hash value?

a. md5()

b. sha1()

c. crc32()

d. All return same length hash

Question:Which of the following characters are taken care of by htmlspecialchars?

a. <

b. >

Page 10: test - php5

c. single quote

d. double quote

e. &

f. All of the above

Question:The classes are defined as follows:abstract class BaseCls{        protected abstract function getName();}

class ChildCls extends BaseCls{

}Which of the following implementations of getName() is invalid in ChildCls?

a. protected function getName(){}

b. function getName(){}

c. private function getName(){}

d. public function getName(){}

Question:In your PHP application you need to open a file. You want the application to issue a warning and continue execution, in case the file is not found. The ideal function to be used is:

a. include()

b. require()

c. nowarn()

d. getFile(false)

Question:Multiple select/load is possible with:

a. Checkbox

b. Select

c. File

d. All of the above

Question:Which of the following is used to maintain the value of a variable over different pages?

a. static

b. global

c. session_register()

Page 11: test - php5

d. None of the above

Question:You need to keep an eye on the existing number of objects of a given class without introducing a non-class member variable. Which of the following makes this happen?

a. Add a member variable that gets incremented in the default constructor and decremented in the destructor  

b. Add a local variable that gets incremented in each constructor and decremented in the destructor

c. Add a static member variable that gets incremented in each constructor and decremented in the destructor

d. This cannot be accomplished since the creation of objects is being done dynamically via "new."  

Question:Consider the following class:

1        class Insurance2        {3           function clsName()4           {5               echo get_class($this);6           }7        }

8        $cl = new Insurance();9        $cl->clsName();10        Insurance::clsName();

Which of the following Lines should be commented to print the class name without errors?

a. Line 8 and 9

b. Line 10

c. Line 9 and 10

d. All the three lines 8,9, and 10 should be left as it is

Question:Which of the following is not true regarding XForms?

a. PHP provides support for XForm

b. It can be used on PDF documents

c. The data is sent in XML format

d. The action and method parameters are defined in the body

Question:Which of the following is not a valid PHP connection status?

a. aborted

b. normal

c. open

d. timeout

Page 12: test - php5

Question:How can you hide the fact that web pages are written in PHP?

a. By using AddType application/x-httpd-php asp

b. Specify all file names without any dot and extension

c. By using .htaccess directive in Apache

d. All of the above

Question:Which of the following variable declarations within a class is invalid in PHP5?

a. private $type = 'moderate';

b. var $term =3;  

c. public $amnt = '500';

d. protected $name = 'Quantas Private Limited';

Question:Given below is a small php script:

<?phpclass person{  function getSal()  {         . . .         . . .  }}class emp extends person{  function getSal()  {           ???  }}?>

The getSal() of emp has to behave exactly as getSal()of person. Which of the following lines of code would you use to replace the '???'

a. parent::getSal();

b. person::getSal();

c. parent::getSal;

d. person::getSal;

Question:What will be the result of the following expression:6+4 * 9-3

a. 60

b. 87

Page 13: test - php5

c. 39

d. 30

Question:Which of the following variable names are invalid?

a. $var_1

b. $var1

c. $var-1

d. $var/1

e. $v1

Question:What will be the ouput of the following code?

<?php

if (-1)    print "true";else    print "false";?>

a. True

b. False

Question:Which of the following statements is not true with regard to abstract classes in php5?

a. Abstract classes are introduced in PHP5

b. A class with a single abstract method must be declared abstract

c. Abstract class can contain non abstract methods

d. Abstract method must have method definition and can have optional empty braces following it

 Question:What will be the output of the following code?

     echo 30 * 5 . 7

a. 150 . 7

b. 1507

c. 150.7

d. you can't concatenate integers

Question:Which of the following are not considered as boolean False?

Page 14: test - php5

a. FALSE

b. 0

c. "0"

d. "FALSE"

e. 1

f. NULL

Question:Which of the following Command Line Interface constant is not defined in the CLI SAPI?

a. STDIN

b. STDOUT

c. STDPRT

d. STDERR

Question:What is the output of the following code?

<?php$a = 3;$b = 2;echo (int)$a / (int)$b?>

a. 1

b. 1.5

c. 2

d. 3

e. Error

Question:With reference to the following php script:

<?php         print 'Text Line1'        print 'Text Line2'?>

What will be the output on running the script?

a. Text Line1Text Line2

b. Text Line1 Text Line2

c. 'Text Line1'

d. 'Text Line2'

e. Error message will be printed

Question:We have two variable definitions:

Page 15: test - php5

1.   \023 2.   \x23

Choose the correct options:

a. 1 is octal

b. 2 is hexadecimal

c. 2 is octal

d. 1 is hexadecimal

Question:What will be the output of following code?

$var1="a";$$var1="b";echo "$var1 $a";

a. a b

b. $var1 $a

c. Error: $a is undefined

d. Error: Parse error in line 2 ($$var1 = "b")