oDesk
PHP 5 Test Answers
1.
ODesk PHP 5 Question: What is true
regarding this code?
ODesk PHP 5 Question Answer: setcookie will return true
ODesk PHP 5 Question Answer: setcookie will return true
2.
ODesk PHP 5 Question: Which of the
following is not a correct way of printing text in php5?
ODesk PHP 5 Question Answer: echo “Plain text”;
ODesk PHP 5 Question Answer: echo “Plain text”;
3.
ODesk PHP 5 Question: Which of the
following is not the correct way of starting a session?
ODesk PHP 5 Question Answer: session_initiate()
ODesk PHP 5 Question Answer: session_initiate()
4.
ODesk PHP 5 Question: Which of the
following functions do you need to implement HTTP Basic Authentication?
ODesk PHP 5 Question Answer: None of the above
ODesk PHP 5 Question Answer: None of the above
5.
ODesk PHP 5 Question: Which of the
following Command Line Interface constant is not defined in the CLI SAPI?
ODesk PHP 5 Question Answer: STDPRT
ODesk PHP 5 Question Answer: STDPRT
6.
ODesk PHP 5 Question: Which of the
following statements is correct with regard to final and abstract?
ODesk PHP 5 Question Answer: a. An abstract class cannot have final methods
ODesk PHP 5 Question Answer: a. An abstract class cannot have final methods
7.
ODesk PHP 5 Question: Which composite data
types are supported by php?
ODesk PHP 5 Question Answer: Array
ODesk PHP 5 Question Answer: Array
8.
ODesk PHP 5 Question: The default value of
register_globals in PHP is:
ODesk PHP 5 Question Answer: Off
ODesk PHP 5 Question Answer: Off
9.
ODesk PHP 5 Question: Which of the
following is not a valid PHP connection status?
ODesk PHP 5 Question Answer: open
ODesk PHP 5 Question Answer: open
10.
ODesk PHP 5 Question: Choose the correct
statement:
ODesk PHP 5 Question Answer: include() includes and evaluates a specific file
require_once() includes and evaluates a specific file only if it has not been included before
ODesk PHP 5 Question Answer: include() includes and evaluates a specific file
require_once() includes and evaluates a specific file only if it has not been included before
11.
ODesk PHP 5 Question: If the
session_cache_expire() is not set, then by default the session cache will
expire after:
ODesk PHP 5 Question Answer: 3 hrs
ODesk PHP 5 Question Answer: 3 hrs
12.
ODesk PHP 5 Question: What will be the
output of the following script?
$count=50;
Paamayim Nekudotayim operator allows access only to the static members of a class?
Paamayim Nekudotayim operator allows access only to the static members of a class?
ODesk PHP 5 Question Answer: function_exists
$i=4;
User Name:
Password:
class Manager{
ODesk PHP 5 Question Answer: 5+2 * 4+6
$var = 1 + “-1.3e3″;
$count=50;
Paamayim Nekudotayim operator allows access only to the static members of a class?
Paamayim Nekudotayim operator allows access only to the static members of a class?
ODesk PHP 5 Question Answer: function_exists
$i=4;
User Name:
Password:
class Manager{
ODesk PHP 5 Question Answer: 5+2 * 4+6
$var = 1 + “-1.3e3″;
function Argument()
{
$count++;
echo $count;
}
Argument();
?>
ODesk PHP 5 Question Answer: It will print 1
{
$count++;
echo $count;
}
Argument();
?>
ODesk PHP 5 Question Answer: It will print 1
13.
ODesk PHP 5 Question: State whether True or
False
ODesk PHP 5 Question Answer: True
ODesk PHP 5 Question Answer: True
14.
ODesk PHP 5 Question: Which of the
following statements is true with regard to comparisons in PHP5?
ODesk PHP 5 Question Answer: With (===) operator, object variables are identical if and only if they refer to the same instance of the same class.
ODesk PHP 5 Question Answer: With (===) operator, object variables are identical if and only if they refer to the same instance of the same class.
15.
ODesk PHP 5 Question: What will be the
output of the following code?
$a = 0.0;
for ($i = 0; $i < a ="="">
ODesk PHP 5 Question Answer: 1
$a = 0.0;
for ($i = 0; $i < a ="="">
ODesk PHP 5 Question Answer: 1
16. ODesk PHP 5 Question: What will be
the output of the following code?
$j=30;
$k=0;
$k=$j++/$i++;
echo $i . ” ” . $j . ” ” . $k . ” “;
ODesk PHP 5 Question Answer: 5 31 7.5
$j=30;
$k=0;
$k=$j++/$i++;
echo $i . ” ” . $j . ” ” . $k . ” “;
ODesk PHP 5 Question Answer: 5 31 7.5
17.
ODesk PHP 5 Question: Which of the
following is a not a correct way of commenting in php?
ODesk PHP 5 Question Answer: /#PHP Comment
ODesk PHP 5 Question Answer: /#PHP Comment
18.
ODesk PHP 5 Question: Following is a php
code block:
$m=9;
$n=99;
$z=8;
$z=$n++/$m++ + –$z;
echo $z;
what will be the output?
ODesk PHP 5 Question Answer: 18
$m=9;
$n=99;
$z=8;
$z=$n++/$m++ + –$z;
echo $z;
what will be the output?
ODesk PHP 5 Question Answer: 18
19.
ODesk PHP 5 Question: Which of the
following is the correct way of specifying default value?
ODesk PHP 5 Question Answer: function GetDiscount($Type = “Special”) { . . . }
ODesk PHP 5 Question Answer: function GetDiscount($Type = “Special”) { . . . }
20.
ODesk PHP 5 Question: With reference to the
following php script:
print ‘Text Line1′
print ‘Text Line2′
?>
What will be the output on running the script?
ODesk PHP 5 Question Answer: Error message will be printed
print ‘Text Line1′
print ‘Text Line2′
?>
What will be the output on running the script?
ODesk PHP 5 Question Answer: Error message will be printed
21.
ODesk PHP 5 Question: What will be the
ouput of the following code?
for ($i = 0; $i < i ="="">
0134
ODesk PHP 5 Question: Late PHP versions support remote file accessing for the functions:
ODesk PHP 5 Question Answer: include_once()
require_once()
both of them
for ($i = 0; $i < i ="="">
0134
ODesk PHP 5 Question: Late PHP versions support remote file accessing for the functions:
ODesk PHP 5 Question Answer: include_once()
require_once()
both of them
22.
ODesk PHP 5 Question: You have designed a
user login form as follows:
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;
ODesk PHP 5 Question Answer: Both of them
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;
ODesk PHP 5 Question Answer: Both of them
23.
ODesk PHP 5 Question: Which of the
following does not represent logical AND operator in PHP?
ODesk PHP 5 Question Answer: &
ODesk PHP 5 Question Answer: &
24.
ODesk PHP 5 Question: Which of the
following is not true for a persistent connection?
ODesk PHP 5 Question Answer: These can’t be converted to non-persistent connections
ODesk PHP 5 Question Answer: These can’t be converted to non-persistent connections
25.
ODesk PHP 5 Question: Which of the
following are invalid data types in PHP?
ODesk PHP 5 Question Answer: char
ODesk PHP 5 Question Answer: char
26.
ODesk PHP 5 Question: The Manager and
Office classes are as follows:
function printName() {
echo “Manager”;
}
}
class Office{
function getManager() {
return new Manager();
}
}
$ofc = new Office();
???
?>
Which of the following should replace ‘???’ to obtain the value of printName() function?
ODesk PHP 5 Question Answer: $ofc->getManager()->printName();
function printName() {
echo “Manager”;
}
}
class Office{
function getManager() {
return new Manager();
}
}
$ofc = new Office();
???
?>
Which of the following should replace ‘???’ to obtain the value of printName() function?
ODesk PHP 5 Question Answer: $ofc->getManager()->printName();
27.
ODesk PHP 5 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?
ODesk PHP 5 Question Answer: public function getName(){}
protected abstract function getName();
}
class ChildCls extends BaseCls{
}
Which of the following implementations of getName() is invalid in ChildCls?
ODesk PHP 5 Question Answer: public function getName(){}
28.
ODesk PHP 5 Question: Which of the
following variable declarations within a class is invalid in PHP5?
ODesk PHP 5 Question Answer: var $term =3;
ODesk PHP 5 Question Answer: var $term =3;
29.
ODesk PHP 5 Question: What will be the
output of following code?
$arr = “a”;
$arr[0]=”b”;
echo $arr;
echo $arr[0];
ODesk PHP 5 Question Answer: bb
$arr = “a”;
$arr[0]=”b”;
echo $arr;
echo $arr[0];
ODesk PHP 5 Question Answer: bb
30.
ODesk PHP 5 Question: For the following
code:
the output will be:
ODesk PHP 5 Question Answer: 171
the output will be:
ODesk PHP 5 Question Answer: 171
31.
ODesk PHP 5 Question: What is the result of
the following expression?
ODesk PHP 5 Question: What will be the output of following code?
echo $var;
ODesk PHP 5 Question Answer: -1299
ODesk PHP 5 Question: What will be the output of following code?
echo $var;
ODesk PHP 5 Question Answer: -1299
32.
ODesk PHP 5 Question: What will be the
output of following code?
$var1=”a”;
$$var1=”b”;
echo “$var1 $a”;
ODesk PHP 5 Question Answer: a b
$var1=”a”;
$$var1=”b”;
echo “$var1 $a”;
ODesk PHP 5 Question Answer: a b
33.
ODesk PHP 5 Question:What is the output of
the following code?
$a = 500;
$b = 200;
echo $a % 2
* $b;
?>
ODesk PHP 5 Question Answer: 0
$a = 500;
$b = 200;
echo $a % 2
* $b;
?>
ODesk PHP 5 Question Answer: 0
34.
ODesk PHP 5 Question: What will be the
ouput of the following code?
if (-1)
print “true”;
else
print “false”;
?>
ODesk PHP 5 Question Answer: true
if (-1)
print “true”;
else
print “false”;
?>
ODesk PHP 5 Question Answer: true
35.
ODesk PHP 5 Question: What will be the
output of the following code?
echo 12 . 6;
ODesk PHP 5 Question Answer: 126
echo 12 . 6;
ODesk PHP 5 Question Answer: 126
36. ODesk PHP 5 Question: Consider the
following sample code:
$x = 0xFFFE;
$y = 2;
$z = $x && $y;
What will be the value of $z?
ODesk PHP 5 Question Answer: 1
$x = 0xFFFE;
$y = 2;
$z = $x && $y;
What will be the value of $z?
ODesk PHP 5 Question Answer: 1
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.