Friday, May 8, 2015

oDesk PHP 5 test answers

No comments



oDesk PHP 5 test answers  for Web designer and Developers to get more job on oDesk.They will be helpful with getting this. They can take a exam on oDesk PHP 5 test answers successfully with help of this post.

 
  
 Ques:     Which composite data types are supported by php?
Ans:     Array
Ques:     The default value of register_globals in PHP is:
Ans:     Off
Ques:     Which of the following is not a valid PHP connection status?
Ans:     open
Ques:     Choose the correct statement:
Ans:      include() includes and evaluates a specific file
require_once() includes and evaluates a specific file only if it has not been included before
Ques:     If the session_cache_expire() is not set, then by default the session cache will expire after:
Ans:     3 hrs
Ques:     What will be the output of the following script?
$count=50;
function Argument()
{
$count++;
echo $count;
}
Argument();
?>
Ans:     It will print 1
Ques:     What is true regarding this code?
Ans:     setcookie will return true
Ques:     Which of the following is not a correct way of printing text in php5?
Ans:     echo "Plain text";
Ques:     Which of the following is not the correct way of starting a session?
Ans:     session_initiate()
                                                                                                                      
Ques:     Which of the following functions do you need to implement HTTP Basic Authentication?
Ans:     None of the above
Ques:     Which of the following Command Line Interface constant is not defined in the CLI SAPI?
Ans:     STDPRT
Ques:     Which of the following statements is correct with regard to final and abstract?
Ans:     a. An abstract class cannot have final methods
Ques:     State whether True or False

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

Ques:     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.

Ques:     Which of the following built-in function assist in checking if actually the function exists or not?
Ans:     function_exists
Ques:     What will be the output of the following code?
$a = 0.0;
for ($i = 0; $i < a ="="">
Ans:     1
Ques:     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
Ques:     Which of the following is a not a correct way of commenting in php?
Ans:     /#PHP Comment
Ques:     Following is a php code block:
$m=9;
$n=99;
$z=8;
$z=$n++/$m++ + --$z;
echo $z;
what will be the output?
Ans:     18
Ques:     Which of the following is the correct way of specifying default value?
Ans:     function GetDiscount($Type = "Special") { . . . }
Ques:     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
Ques:     What will be the ouput of the following code?
for ($i = 0; $i < i ="="">
0134
Ques:     Late PHP versions support remote file accessing for the functions:
Ans:     include_once()
          require_once()
both of them
Ques:     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
Ques:     Which of the following does not represent logical AND operator in PHP?
Ans:     &amp
Ques:     Which of the following is not true for a persistent connection?
Ans:     These can't be converted to non-persistent connections
Ques:     Which of the following are invalid data types in PHP?
Ans:     char
Ques:     The Manager and Office classes are as follows:
class Manager{
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?
Ans:     $ofc->getManager()->printName();
Ques:     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(){}
Ques:     Which of the following variable declarations within a class is invalid in PHP5?
Ans:     var $term =3;
Ques:     What will be the output of following code?
$arr = "a";
$arr[0]="b";
echo $arr;
echo $arr[0];
Ans:     bb
Ques:     For the following code:
the output will be:
Ans:     171
Ques:     What is the result of the following expression?
Ans:     5+2 * 4+6
Ques:     What will be the output of following code?
$var = 1 + "-1.3e3";
echo $var;
Ans:     -1299
Ques:     What will be the output of following code?
$var1="a";
$$var1="b";
echo "$var1 $a";
Ans:     a b
Ques:    What is the output of the following code?
$a = 500;
$b = 200;
echo $a % 2
* $b;
?>
Ans:     0
Ques:     What will be the ouput of the following code?
if (-1)
print "true";
else
print "false";
?>
Ans:     true
Ques:     What will be the output of the following code?
echo 126;
Ans:     126
Ques:     Consider the following sample code:
$x = 0xFFFE;
$y = 2;
$z = $x && $y;
What will be the value of $z?
Ans:     1 

oDesk PHP Test Answers  2015
Ques: The setrawcookie() method of setting cookies is different from PHP standard method of cookie setting as:
  1. It does not allow expiry time to be set
  2. It can be used only once
  3. It does not URL-ENCODE the value on its own
d.It does not allow domain setting
Ans: C
Ques: You need to keep an eye on the existing number of objects of a given class without introducing a non-class varibale. which of the following makes this happen?
  1. Add a member varibale that gets incremented in the default constructer and decremented the destructer.
  2. Add a local variable that gets incremented in each constructer and decremented in the desructer
  3. Add a static member variable that gets incremented in each constructer and decreented in the destructor
  4. This cannot be accomplished since the creation of objects is being done dynamically via “new”
Ans: c
Ques: which of the following variable declaration within a class is invalid in PHP5?
  1. private $type = “moderate”;
  2. var $term = 3;
  3. public $amn = “500″;
  4. protected $name = ‘Quantes Private Limited’;
Ans: d
Ques: which of the following is not valid PHP parser tag?
  1. script
  2. ?p
  3. %
  4. ?php;
Ans: c
Ques: How can you hide the fact that web pages are written in PHP?
  1. By using AddType application/X-httpd-php asp
  2. Specify all file names without any dot and extension
  3. By using .htaccess diretive in Apeche
  4. All of the above
Ans: C
Ques: What is the output of the following code?
$a = 3;
$b = 2;
echo (int)$a/(int)$b
?>
  1. 1
  2. 1.5
  3. 2
  4. 3
  5. Eroor
Ans: b
Ques: Which one is correct?
  1. $s = fwrite (“a string here”);
  2. $s = fwrite ($fp,”a string here”);
  3. $s = fwrite (“a string here”,$fp);
  4. non of the above
Ans: b
Ques: Which of the following set of operations is not valid in PHP 5?
  1. >, >=
  2. =,==
  3. !==,!==
  4. +=, *=
Ans: C
Ques: Late PHP version support remote file accessing for the functions:
  1. include()
  2. include_once()
  3. require_once()
  4. All of the above
Ans: D
Ques: What will be the output of the following script?
$count=50;
function Argument()
{
$count++;
echo $count;
}
Argument()
?>
  1. It will print 50
  2. It will print 51
  3. It will print 52
  4. It will print 1
Ans: D
Ques: which of the following are used for code reuse?
  1. Loops
  2. functions
  3. Database
  4. include files
Ans: B,D
Ques: which of the following is the corect way of specifying default value?
  1. Function GetDiscount($Type = “Special”) {………}
  2. Function GetDiscount(Type := “Special”) {………}
  3. Function GetDiscount($Type: = “Special”) {………}
  4. Function GetDiscount($Type : “Special”) {………}
Ans: b
Ques: Which of the following are “magic constant”?
  1. __LINE__
  2. __FILE__
c __PRETTY_FUNCTION__
d __CLASS__
  1. __METHOD__
Ans: c
Ques: you have defined three variables $to, $subject, and $body to send an email. Which of the following methods would you use for sending an email?
  1. mail($to, $subject,$body)
  2. sendmail($to, $subject,$body)
  3. mail(to, subject,body)
  4. sendmail(to, subject,body)
Ans: a
Ques: Which one of the following is turnary operator?
  1. &
  2. =

  3. ?:
  4. +=
  5. &&
Ans: D
Ques: What is the result of the following Exprssion?
5+2*4+6
  1. 70
  2. 19
  3. 34
  4. 21
Ans: B
Ques: The default value of register global in PHP is:
  1. Off
  2. On
Ans: A
Ques: What would b the outpur of the following code?
$string = ‘good day’;
$string = ucword($string);
echo $string;
?>
  1. good day
  2. GOOD DAY
  3. Good Day
  4. non of the above
Ans: C
Ques: If you want to pass a value to a function by reference, the correct way is:
  1. function ModifyReport(&$Rptfile){}
  2. function ModifyReport($Rptfile){}
  3. function ModifyReport(ByRef $Rptfile){}
  4. function ModifyReport(&Rptfile){}
Ans: D


No comments :

Post a Comment