oDesk Test Answar PHP5 2013/2014


Question 1:
What will be the result of following operation?
Print 4<<5;
  1. 3
  2. 128
  3. 120
  4. 6
Answer is:       120

Question 2:
You wrote following script to check for the right category:
  1. 2
  2. $cate=5;
  3. ...
  4.  
  5. if ($cate==5)
  6. {
  7. ?>
  8. Correct category!
  9. 11 }
  10. else {
  11. ?>
  12. Incorrect category!
  13. 15 }
  14. }
  15. ?>
What will be the output of the program if value of ‘cate’ remains 5?
  1. Correct category!
  2. Incorrect category!
  3. Error due to use of invalid operator in line 6:”if ($cate==5)”
  4. Error due to incorrect syntax at line 8, 10, 12 and 14
Answer is:       Correct category!

Question 3:
You need to count the number of parameters given in the URL by a POST operation. The correct way is:
  1. count($POST_VARS);
  2. count($POST_VARS_PARAM);
  3. count($_POST);
  4. count($HTTP_POST_PARAM);
Answer is:       count($_POST);

Question 4:
If expire parameter of setCookie function is not specified then:
  1. Cookie will never expire.
  2. Cookie will expire with closure of the browser
  3. Cookie will expire with within 30 minutes
  4. Cookie will expire in 24 hours
Answer is:       Cookie will expire with closure of the browser

Question 5:
Which of the following variables declarations within a class is invalid in PHP5?
  1. Private $type = ‘moderate’;
  2. Internal $term =3;
  3. Public $name =’500’;
  4. Protected $name = ‘Quantas Private Limited’;
Answer is:       Protected $name = ‘Quantas Private Limited’;

Question 6:
Which of the following statements is not true with regard to abstract classes in PHP5?
  1. Abstract classes are introduced in PHP5
  2. A class with a single abstract method must be declared abstract
  3. Abstract class can contain non abstract methods
  4. Abstract method must have method definition and can have optional empty braces following it
Answer is:       Abstract method must have method definition and can have optional empty braces following it

Question 7:
Which of the following pair have non-associative equal precedence?
  1. +,-
  2. ==, !=
  3. <<, >>
  4. &=, |=
Answer is:       &=, |=empty braces following it

Question 8:
You have two strings, which you want to concatenate.
$str1 = ‘Have a ‘;
$str2 = ‘Nice Day’;
The fastest way would be:
  1. $str1. Concat($str2);
  2. $str1. $str2;
  3. “$str1$str2”;
  4. None of the above
Answer is:       None of the above

Question 9:
For the following code:
  1. Function Expenses()
  2. {
  3. Function Salary()
  4. {
  5. }
  6. Function Loan()
  7. {
  8. Function Balance()
  9. {
  10. }
  11. }
  12. ?>
Which of the following sequence will run successfully?
  1. Expenses();Salary();Loan();Balance();
  2. Salary();Expenses();Loan();Balance();
  3. Expenses();Salary();Balance();Loan();
  4. Balance();Loan();Salary();Expenses();
Answer is:       Salary();Expenses();Loan();Balance();

Question 10:
Which of the following is not supported in PHP5?
  1. Type Hinting
  2. Reflection
  3. Magic Methods         
  4. Multiple Inheritance
  5. Object Cloning
Answer is:       Multiple Inheritance

Question 11:
How would you start a session?
  1. Session(start);
  2. Session();
  3. Session_Start();
  4. Begin_sesion();
Answer is:       Session_Start();

Question 12:
What do you infer from the following code?
$str=’Dear Customer,\nThanks for your query. We will reply very soon.?\n Regards.\n Customer Service Agent’: Print $str;
?>
  1. Only first\n Character will be recognized and new line will be inserted.
  2. Last \n Will not be recognized and only first two parts will come in new lines.
  3. All the \n Will work and text will be printed on respective new lines.
  4. All will be printed on one line irrespective of the \n.
Answer is:       All the \n Will work and text will be printed on respective new lines.  

Question 13:
What will be the result of the following expression:
6+4*9-3
  1. 60
  2. 87
  3. 39
  4. 30
Answer is:       87

Question 14:
What is true regarding $a+$b where both of them are arrays?
  1. Duplicated keys are NOT overwritten
  2. 87
  3. The + operator is overloaded
  4. This produces a syntax error
Answer is:       $b is appended to $a

Question 15:
Which of the following characters are taken care of by html special chars?
  1. <
  2. >
  3. Single quote
  4. Double Quote
  5. &
  6. All of the above
Answer is:       >

Question 16:
The value of a local variable of a function has to be retained over multiple calls to that function. How should that variable be declared?
  1. Local
  2. Global
  3. Static
  4. None of the above
Answer is:       Static

Question 17:
Which of the following multithreaded servers allow PHP as a plug-in?
  1. Netscape FastTrack
  2. Microsoft’s Internet Information Server
  3. O’Reilly’s WebSite Pro
  4. All of the above
Answer is:       All of the above

Question 18:
Multiple select/load is possible with:
  1. Checkbox
  2. Select
  3. File
  4. All of the above
Answer is:       All of the above

Question 19:
Which of the following variable names are invalid?
  1. $var_1
  2. $var1
  3. $var-1
  4. $var/1
  5. $v1
Answer is:       $var1

Question 20:
Which of the following are useful for method overloading?
  1. _call,_get,_set
  2. _get,_set,_load
  3. _get,_set,_load
  4. _overload
Answer is:       _get,_set,_load

Question 21:
What will be the output of the following code?
Function fn(&$var)
{
$var=$var-($var/10*5);
Return $var;
}
Echo fn(100);
  1. 100
  2. 50
  3. 98
  4. Error message
  5. None of the above
Answer is:       None of the above

Question 22:
Which of the following type cast is not correct?
  1. $fig=23;
  2. $varb1 = (real) $fig;
  3. $varb2 = (double) $fig;
  4. $varb3 = (decimal) $fig;
  5. $varb4 = (bool) $fig;
  6. ?>
  1. Real
  2. Double
  3. Decimal
  4. Boolean
Answer is:       Double

Question 23:
What will be the output of following code?
$a = 10;
Echo “value of a = $a”;
  1. Value of a = 10
  2. Value of a = $a
  3. Undefined
  4. Syntax Error
Answer is:       Value of a = $a

Question 24:
What will be the output of following code?
$var = 10;
Function fn()
{
$var = 20;
Return $var;
}
Fn();
Echo $var;
  1. 10
  2. 20
  3. Undefined Variable
  4. Syntax Error
Answer is:       Syntax Error

Question 25:
Which of the following attribute is needed for file upload via form?
  1. Enctype=”multipart/form-data”
  2. Enctype=”singlepart/data”
  3. Enctype=”file”
  4. Enctype=” form-data/file”
Answer is:       Enctype=”file”

Question 26:
Which of the following is not a file related function in PHP?
  1. Fclose
  2. Fopen
  3. Fwrite
  4. Fgets
  5. Fappend
Answer is:       Fgets

Question 27:
Which of the following is correct with regard to echo and print?
  1. Echo is a construct and print is a function
  2. Echo is a function and print is a construct
  3. Both are functions
  4. Both are constructs
Answer is:       Echo is a function and print is a construct

Question 28:
Which of the following is a correct declaration?
  1. Static $varb = array(1,’val’,3);
  2. Static $varb = 1+(2*90);
  3. Static $varb = sqrt(81);
  4. Static $varb = new object;
Answer is:       Static $varb = new object;

Question 29:
Consider the following two statements:
I.          While (expr) statement
II.         While (expr): statement…endwhile;
Which of the following are true in context of the given statements?
  1. I is correct and II is wrong
  2. I is wrong and II is correct
  3. Both I & II are wrong
  4. Both I & II are correct
Answer is:       I is wrong and II is correct

Question 30:
You are using sessions and session register() to register objects. These objects are serialized automatically at the end of each PHP page and are de-serialized automatically on each of the following pages. Is this true of false?
  1. True
  2. False
Answer is:       True


1 comment:

Popular Posts