Thursday, March 21, 2013

oDesk PHP 5 Test Answers

odesk test answer

Question:
Which of the following is not a correct way of printing text in php5?
Ans: echo "Plain text";

Question:
Which of the following is not the correct way of starting a session?
Ans: session_initiate()
                                                                                                                      
Question:
Which of the following functions do you need to implement HTTP Basic Authentication?
Ans: None of the above

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

Question:
Which of the following statements is correct with regard to final and abstract?
Ans: a. An abstract class cannot have final methods

Question:
Which composite data types are supported by php?
Ans: Array

Question:
The default value of register_globals in PHP is:
Ans: Off

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

Question:
Choose the correct statement:
include() includes and evaluates a specific file
Ans: require_once() includes and evaluates a specific file only if it has not been included before

Question:
If the session_cache_expire() is not set, then by default the session cache will expire after:
Ans: 3 hrs

Question:
What will be the output of the following script?
$count=50;
function Argument()
{
$count++;
echo $count;
}
Argument();
?>
Ans: It will print 1

Question:
State whether True or False
Paamayim Nekudotayim operator allows access only to the static members of a class?
Ans: True

Question:
Which of the following statements is true with regard to comparisons in PHP5?
Ans: With (===) operator, object variables are identical if and only if they refer to the same instance of the same class.

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

Question:
What will be the output of the following code?
$a = 0.0;
for ($i = 0; $i < a ="="">
Ans: 1

Question:
What will be the output of the following code?
$i=4;
$j=30;
$k=0;
$k=$j++/$i++;
echo $i . " " . $j . " " . $k . " ";
Ans: 5 31 7.5

Question:
Which of the following is a not a correct way of commenting in php?
Ans: /#PHP Comment

Question:
Following is a php code block:
$m=9;
$n=99;
$z=8;
$z=$n++/$m++ + --$z;
Ans: echo $z;

what will be the output?
Ans: 18

Question:
Which of the following is the correct way of specifying default value?
Ans: function GetDiscount($Type = "Special") { . . . }

Question:
With reference to the following php script:
print 'Text Line1'
print 'Text Line2'
Ans:?>

What will be the output on running the script?
Ans: Error message will be printed

Question:
What will be the ouput of the following code?
for ($i = 0; $i < i ="="">
Ans: 0134

Question:
Late PHP versions support remote file accessing for the functions:
include_once()
require_once()
Ans: both of them


Question:
You have designed a user login form as follows:
User Name:
Password:
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;
Ans: Both of them

Question:
Which of the following does not represent logical AND operator in PHP?
Ans: &amp

Question:
Which of the following is not true for a persistent connection?
Ans: These can't be converted to non-persistent connections

Question:
Which of the following are invalid data types in PHP?
Ans: char

Question:
The Manager and Office classes are as follows:
class Manager{
function printName() {
echo "Manager";
}
}
class Office{
function getManager() {
return new Manager();
}
}

$ofc = new Office();
???
Ans:?>

Which of the following should replace '???' to obtain the value of printName() function?
Ans: $ofc->getManager()->printName();

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?
Ans: public function getName(){}

Question:
Which of the following variable declarations within a class is invalid in PHP5?
Ans: var $term =3;
Question:
What will be the output of following code?
$arr = "a";
$arr[0]="b";
echo $arr;
echo $arr[0];
Ans: bb

Question:
For the following code:
the output will be:
Ans: 171

Question:
What is the result of the following expression?
5+2 * 4+6
Ans: 19

Question:
What will be the output of following code?
$var = 1 + "-1.3e3";
echo $var;
Ans: -1299

Question:
What will be the output of following code?
$var1="a";
$$var1="b";
echo "$var1 $a";
Ans: a b

Question:What is the output of the following code?
$a = 500;
$b = 200;

echo $a % 2
* $b;
?>
Ans: 0

Question:
What will be the ouput of the following code?
if (-1)
print "true";
else
print "false";
?>
Ans: true

Question:
What will be the output of the following code?
echo 12 . 6;
Ans: 126

Question:
Consider the following sample code:
$x = 0xFFFE;
$y = 2;
$z = $x && $y;
What will be the value of $z?
Ans: 1

What is true regarding this code?
Ans: setcookie will return true

Question:
Which of the following is not a correct way of printing text in php5?
Ans: echo "Plain text";

Question:
Which of the following is not the correct way of starting a session?
Ans: session_initiate()
                                                                                                                     
Question:
Which of the following functions do you need to implement HTTP Basic Authentication?
Ans: None of the above

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

Question:
Which of the following statements is correct with regard to final and abstract?
Ans: a. An abstract class cannot have final methods

Question:
Which composite data types are supported by php?
 Ans: Array

Question:
The default value of register_globals in PHP is:
Ans: Off

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

Question:
Choose the correct statement:
include() includes and evaluates a specific file
require_once() includes and evaluates a specific file only if it has not been included before

Question:
State whether True or False
Paamayim Nekudotayim operator allows access only to the static members of a class?
Ans: True

Question:
Which of the following statements is true with regard to comparisons in PHP5?
Ans: With (===) operator, object variables are identical if and only if they refer to the same instance of the same class.

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


Question:
Which of the following is the correct way of specifying default value?
Ans: function GetDiscount($Type = "Special") { . . . }

Question:
With reference to the following php script:
print 'Text Line1'
print 'Text Line2'
?>
What will be the output on running the script?
Ans: Error message will be printed

Question:
What will be the ouput of the following code?
for ($i = 0; $i < i ="="">
Ans: 0134

Question:
Late PHP versions support remote file accessing for the functions:
include_once()
require_once()
Ans: both of them

Question:
You have designed a user login form as follows:
User Name: 
Password: 
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;
Ans: Both of them

Question:
Which of the following is not true for a persistent connection?
Ans: These can't be converted to non-persistent connections

Question:
Which of the following are invalid data types in PHP?
Ans: char

Which of the following should replace '???' to obtain the value of printName() function?
Ans: $ofc->getManager()->printName();

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?
Ans:  public function getName(){}

Question:
Which of the following variable declarations within a class is invalid in PHP5?
Ans: var $term =3;


Question:
What is the result of the following expression?
Ans: 5+2 * 4+6





Question:
What will be the ouput of the following code?
if (-1)
print "true";
else
print "false";
?>
Ans: true

Question:
What will be the output of the following code?
Ans: echo 12 . 6;
126

Question.
which of the following are used for code reuse?
Ans: B,D

:

Question.
Which one of the following is turnary operator?
Ans: D

Question.
What is the result of the following Exprssion?
5+2*4+6
Ans: B

Question.
The default value of register global in PHP is:
Ans: A

Question.
What would b the outpur of the following code?
$string = 'good day';
$string = ucword($string);
echo $string;
?>
Ans: C

Question.
If you want to pass a value to a function by reference, the correct way is:
Ans: D

Question1:
What will be the result of following operation?
Ans: print 4<< 5;
c.     120      

Question
You wrote following script to check for the right category:
1        2        $cate=5;
3        ...
4        ...
5      
6        if ($cate==5)
7        {
8        ?>
9          Correct category!
10        11        } else {
12        ?>
13          Incorrect category!
14        15        }
16        ?>
What will be the output of the program if value of 'cate' remains 5?
Ans: a. Correct category!      

Question
You need to count the number of parameters given in the URL by a POST operation. The correct way is:
Ans:c. count($_POST);      


Question
If expire parameter of setCookie function is not specified then:
Ans: b.  Cookie will expire with closure of the browser      

Question
Which of the following variable declarations within a class is invalid in PHP5?
Ans: d. protected $name = 'Quantas Private Limited';      

Question
Which of the following statements is not true with regard to abstract classes in php5?
Ans: d.     Abstract method must have method definition and can have optional empty braces following it
       
Question
Which of the following pair have non-associative equal precedence?
Ans: d. &=, |=      

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete