Sunday, 3 August 2014

oDesk update PHP5 Test Questions with Answer



oDesk update PHP5 Test Questions with Answer

1. load is possible with:
A. checkbox
B. select
C. file
D. all of the above
Ans : A
2. State whether true or false
Paamayim nekudotayim operator allows access only to the static members of a class?
a. True
b. False
Ans: A
3. What is the output of the following code?
$a=500;
$b=200;
echo $a % 2 * $b;
a. 100
b. 200
c. 500
d. 0
e. Syntax error
Ans: D
4. which function will suitable replace “X”?
a. Filesize
b. Size
c. sizeofFile
d. getSize
Ans: A
5. Which of the following is not true for a persistent connection?
a. these are not closed even after the execution of the script
b. these are mainly used to increase the efficiency of thesystem
c. These can’t be converted to non-persistent connections
d. These are preferable not used in the scripts involving transactions
Ans: C
6. 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
Ans: B
7. Which will be the output of the following code?
$a=0.0;
For($i=0;$i
the getSal() of emp has to behave exacltyle as getSal() ofperson . 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;
Ans: A
11. What is true regarding this code?
a. setcookie will return false
b. setcookie will return true
c. setcookie will return null
d. Any of the above can happen
Answer: b
12. Which of the following is not the correct way of starting a session?
a. session.auto_start
b. session_register()
c. session_initiate()
d. session_start()
Answer: c;
13. Which of the following functions do you need to implement HTTP Basic Authentication?
a. authenticate ()
b. header ()
c. basic_auth ()
d. None of the above
Answer: d;
14. Which of the following Command Line Interface constant is not defined in the CLI SAPI?
a. STDIN
b. STDOUT
c. STDPRT
d. STDERR
Answer: c;
15. Which of the following statements is correct with regard to final and abstract?
a. An abstract class cannot have final methods
b. An abstract class cannot have non abstract methods
c. A final class cannot have abstract methods
d. A final class cannot have final methods
Answer: C
Explanation :
a. An abstract class can have final method.
b. An abstract class can have other than abstract method.
c. a final class can have final method (but not a must requirement).
d. BUT a final class cannot have abstract method.
16. Which composite data types are supported by php?
a. Array
b. Enumeration
c. List
d. Object
e. Integer
Answer: A and D
17. The default value of register_globals in PHP is:
a. Off
b. On
Answer A
18. Using Register Globals
WarningThis feature has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.
Perhaps the most controversial change in PHP is when the default value for the PHP directive register_globals went from ON to OFF in PHP » 4.2.0.
Choose the correct statement:
a. include() includes and evaluates a specific file
b. require() includes and evaluates a specific file
c. include_once() includes and evaluates a specific file only if it has not been included before
d. require_once() includes and evaluates a specific file only if it has not been included before
e. All of the above
Answer: E
19. If the session_cache_expire() is not set, then by default the session cache will expire after:
a. 1 hr
b. 2 hrs
c. 3 hrs
d. 4 hrs
Answer: C
20. The cache expire is reset to the default value of 180 stored in session.cache_expire at request startup time. Thus, you need to call session_cache_expire() for every request (and before session_start() is called).
What will be the output of the following script?
$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
Answer: D;
Explanation : $count is local in the method.
21. 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.
Answer C;
21. What will be the output of the following code?
$i=4;
$j=30;
$k=0;
$k=$j++/$i++;
echo $i . ” ” . $j . ” ” . $k . ” “;
a. 5 31 6
b. 5 31 6.2
c. 5 31 7
d. 4 31 7.5
e. 5 31 7.5
Answer e;
Explanation : After increment then Divition command will execute.
22. Which of the following is a not a correct way of commenting in php?
a. //PHP Comment
b. /*PHP Comment*/
c. #PHP Comment
d. /#PHP Comment
Answer d;
23. Following is a php code block:
$m=9;
$n=99;
$z=8;
$z=$n++/$m++ + –$z;
echo $z;
what will be the output?
a. 16
b. 18
c. 19
d. 20
e. 17
Answer: B; (?? not understand)
24. Which of the following is the correct way of specifying default value?
a. function GetDiscount($Type = “Special”) { . . . }
b. function GetDiscount(Type := “Special”) { . . . }
c. function GetDiscount($Type := “Special”) { . . . }
d. function GetDiscount($Type : “Special”) { . . . }
Answre a;
25. With reference to the following php script:
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
Answer e;
26. Late PHP versions support remote file accessing for the functions:
a. include()
b. include_once()
c. require_once()
d. Both a and b
e. Both b and c
Answer: e;
27. Which of the following does not represent logical AND operator in PHP?
a. &
b. &&
c. And
d. AND
Answer: a
28. Which of the following are invalid data types in PHP?
a. string
b. integer
c. float
d. char
e. array
f. object
Answer: D
29. 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?
a. $ofc->getManager()->printName();
b. new Office()->getManager()->printName();
c. $ofc->getManager->printName;
d. Office::getManager()::printName();
Answer: a
30.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’;
Answer: b;
31. What will be the output of following code?
$arr = “a”;
$arr[0]=”b”;
echo $arr;
echo $arr[0];
a. ab
b. $arr is undefined
c. bb
d. Parse error
Answer: C
32. What is the result of the following expression?
5+2 * 4+6
a. 70
b. 19
c. 34
d. 21
Anwer: b
33. What will be the output of following code?
$var = 1 + “-1.3e3?;
echo $var;
a. -1299
b. 1
c. 1-1.3e3
d. Error:cannot add integer and string
An swer: a
34. 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”)
Answer a
35. What will be the ouput of the following code?
if (-1)
print “true”;
else
print “false”;
?>
a. true
b. false
Answer: a
36. 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(.)
Answer: B
37. Consider the following sample code:
$x = 0xFFFE;
$y = 2;
$z = $x && $y;
What will be the value of $z?
a. 0
b. 1
c. 2
d. 3
e. 4
Answer: B
38. what would be the output of the following code?
$stg=’good day’;
$stg= ucwords($stg);
echo $stg;
?>
a. good day
b. GOOD DAY
c. Good Day
d None of the above
Ans: C
39. Which one of the following is turnary operator?
a. &
b. =
c. :?
d. ?:
e. +=
f. &&
Ans: D
40. If you want to pass a value to a function by reference, the correct way is:
a. function ModifyReport(&$Rptfile){}
b. function ModifyReport($Rptfile){}
c. function ModifyReport(ByRef $Rptfile){}
d. function ModifyReport(&Rptfile){}
Ans: A

0 comments:

Post a Comment