oDesk Test Answar PHP5 2013/2014
Question 1:
What will be the result of following operation?
What will be the result of following operation?
Print 4<<5;
- 3
- 128
- 120
- 6
Answer is: 120
Question 2:
You wrote following
script to check for the right category:
- 2
- $cate=5;
- ...
- …
- if ($cate==5)
- {
- ?>
- Correct category!
- 11 }
- else {
- ?>
- Incorrect category!
- 15 }
- }
- ?>
What will be the
output of the program if value of ‘cate’ remains 5?
- Correct category!
- Incorrect category!
- Error due to use of invalid operator in line 6:”if ($cate==5)”
- 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:
- count($POST_VARS);
- count($POST_VARS_PARAM);
- count($_POST);
- count($HTTP_POST_PARAM);
Answer
is: count($_POST);
Question 4:
If expire parameter
of setCookie function is not specified then:
- Cookie will never expire.
- Cookie will expire with closure of the browser
- Cookie will expire with within 30 minutes
- 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?
- Private $type = ‘moderate’;
- Internal $term =3;
- Public $name =’500’;
- 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?
- Abstract classes are introduced in PHP5
- A class with a single abstract method must be declared abstract
- Abstract class can contain non abstract methods
- 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?
- +,-
- ==, !=
- <<, >>
- &=, |=
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:
- $str1. Concat($str2);
- $str1. $str2;
- “$str1$str2”;
- None of the above
Answer
is: None of the above
Question 9:
For the following
code:
- Function Expenses()
- {
- Function Salary()
- {
- }
- Function Loan()
- {
- Function Balance()
- {
- }
- }
- ?>
Which of the
following sequence will run successfully?
- Expenses();Salary();Loan();Balance();
- Salary();Expenses();Loan();Balance();
- Expenses();Salary();Balance();Loan();
- Balance();Loan();Salary();Expenses();
Answer
is: Salary();Expenses();Loan();Balance();
Question 10:
Which of the
following is not supported in PHP5?
- Type Hinting
- Reflection
- Magic Methods
- Multiple Inheritance
- Object Cloning
Answer
is: Multiple Inheritance
Question 11:
How would you start
a session?
- Session(start);
- Session();
- Session_Start();
- 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;
?>
- Only first\n Character will be recognized and new line will be inserted.
- Last \n Will not be recognized and only first two parts will come in new lines.
- All the \n Will work and text will be printed on respective new lines.
- 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
6+4*9-3
- 60
- 87
- 39
- 30
Answer
is: 87
Question 14:
What is true
regarding $a+$b where both of them are arrays?
- Duplicated keys are NOT overwritten
- 87
- The + operator is overloaded
- 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?
- <
- >
- Single quote
- Double Quote
- &
- 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?
- Local
- Global
- Static
- None of the above
Answer
is: Static
Question 17:
Which of the
following multithreaded servers allow PHP as a plug-in?
- Netscape FastTrack
- Microsoft’s Internet Information Server
- O’Reilly’s WebSite Pro
- All of the above
Answer
is: All of the above
Question 18:
Multiple select/load
is possible with:
- Checkbox
- Select
- File
- All of the above
Answer
is: All of the above
Question 19:
Which of the
following variable names are invalid?
- $var_1
- $var1
- $var-1
- $var/1
- $v1
Answer
is: $var1
Question 20:
Which of the
following are useful for method overloading?
- _call,_get,_set
- _get,_set,_load
- _get,_set,_load
- _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);
- 100
- 50
- 98
- Error message
- None of the above
Answer
is: None of the above
Question 22:
Which of the
following type cast is not correct?
- $fig=23;
- $varb1 = (real) $fig;
- $varb2 = (double) $fig;
- $varb3 = (decimal) $fig;
- $varb4 = (bool) $fig;
- ?>
- Real
- Double
- Decimal
- Boolean
Answer
is: Double
Question 23:
What will be the
output of following code?
$a = 10;
Echo “value of a =
$a”;
- Value of a = 10
- Value of a = $a
- Undefined
- 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;
- 10
- 20
- Undefined Variable
- Syntax Error
Answer
is: Syntax Error
Question 25:
Which of the
following attribute is needed for file upload via form?
- Enctype=”multipart/form-data”
- Enctype=”singlepart/data”
- Enctype=”file”
- Enctype=” form-data/file”
Answer
is: Enctype=”file”
Question 26:
Which of the
following is not a file related function in PHP?
- Fclose
- Fopen
- Fwrite
- Fgets
- Fappend
Answer
is: Fgets
Question 27:
Which of the
following is correct with regard to echo and print?
- Echo is a construct and print is a function
- Echo is a function and print is a construct
- Both are functions
- Both are constructs
Answer
is: Echo is a function and print is a
construct
Question 28:
Which of the
following is a correct declaration?
- Static $varb = array(1,’val’,3);
- Static $varb = 1+(2*90);
- Static $varb = sqrt(81);
- 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?
- I is correct and II is wrong
- I is wrong and II is correct
- Both I & II are wrong
- 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?
- True
- False
Answer is: True
Very nice. Thanks for the most updated supplement.
ReplyDelete