Wednesday, January 9, 2013

oDesk PHP 5 Test Answers

oDesk PHP 5 Test Answers

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

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

8 comments:

  1. Wow....Nice posting.....For New Updated Sites list 2016 of social bookmarking websites.Visit our……… Submityourwebsite.xyz
    Addlinks.xyz
    Addwebsite.xyz
    Addyourwebsite.xyz
    Freelinking.xyz
    Freesubmission.xyz
    Freeurl.xyz
    Freeurls.xyz
    Freewebsitesubmission.xyz
    Linkyourwebsite.xyz
    Postwebsite.xyz
    Publishednews.xyz
    Seosubmission.xyz
    Submitanewstory.xyz
    Submitbookmark.xyz
    Submitlinks.xyz
    Submitnewlink.xyz
    Submitnewlinks.xyz
    Submitwebsites.xyz
    Websitelinking.xyz
    Postclassifieds.xyz
    Postfreead.xyz
    Postfreeclassifiedads.xyz

    ReplyDelete
  2. Nice collection buddy.Thanks for sharing.Here we have New social bookmarking sites list……Linktoday.xyz
    Publishedlinks.xyz
    Superlinking.xyz
    Seoonlinenews.xyz
    Getbestseorank.xyz
    Writeanewpost.xyz
    Bookarkseo.xyz
    Bookmark143.xyz
    Seosocialbookmarking.xyz
    Socialposts.xyz
    Mybestlinks.xyz
    Bestseorank.xyz
    Amazinglinks.xyz
    Myfavoritelinks.xyz
    1morelink.xyz
    Createfreeblog.xyz
    Yourfreeblog.xyz
    Savemylink.xyz
    Sharemypost.xyz
    Twomorelinks.xyz
    Shareyourwebsite.xyz
    Seobacklinks.xyz
    Myseonews.xyz
    Thenextlink.xyz
    Getfreewebsite.xyz
    Yourfreewebsite.xyz
    Dailybookmark.xyz
    Givemelink.xyz

    ReplyDelete
  3. This information really worth saying, i think you are master of the content and thank you so much sharing that valuable information and get new skills after refer that post.
    SEO Company in Chennai

    ReplyDelete
  4. HAPPY NEW YEAR 2018 I LOVE THESE TYPES OF POSTS VERY MUCH BECAUSE THEY ARE VERY INFORMATIVE. I WANT YOOU TO PUBLISH SUCH POSTS ATLEAST TWICE A WEEK FOR VISITORS LIKE US

    ReplyDelete
  5. HAPPY NEW YEAR 2018 I LOVE THESE TYPES OF POSTS VERY MUCH BECAUSE THEY ARE VERY INFORMATIVE. I WANT YOOU TO PUBLISH SUCH POSTS ATLEAST TWICE A WEEK FOR VISITORS LIKE US

    ReplyDelete
  6. I like your article very useful and very interesting. I will share it with my friends too. Thanks for this lovey post cinema box app android

    ReplyDelete

 
Twitter Bird Gadget UA-33677056-1