| 2 التعليقات ]

odesk PHP5 Test answers 2012 (40 answers)

Hello to every one. in this tutorial i will show you how to pass the odesk PHP5 Test 2012 (40 answers)

 Question1:
What will be the result of following operation?
print 4<< 5;


    a.     3
    b.     128
    c.     120
    d.     6

 the answers is:
    c.     120       

 Question2:
You wrote following script to check for the right category:

1        2        $cate=5;
3        ...
4        ...
5       
6        if ($cate==5)
7        {
8        ?>
9          Correct category!
10        11        } else {
12        ?>
13          Incorrect category!
14        15        }
16        ?>

What will be the output of the program if value of 'cate' remains 5?


    a.     Correct category!
    b.     Incorrect category!
    c.     Error  due to use of invalid operator in line 6:"if ($cate==5)"
    d.     Error due to incorrect syntax at line 8, 10, 12 and 14

 the answers is:
    a.     Correct category!       

 Question3:
You need to count the number of parameters given in the URL by a POST operation. The correct way is:


    a.     count($POST_VARS);
    b.     count($POST_VARS_PARAM);
    c.     count($_POST);
    d.     count($HTTP_POST_PARAM);

 the answers is:
    c.     count($_POST);       

 Question4:
If expire parameter of setCookie function is not specified then:


    a.     Cookie will never expire.
    b.     Cookie will expire with closure of the browser
    c.     Cookie will expire with within 30 minutes
    d.     Cookie will expire in 24 hours

 the answers is:
    b.     Cookie will expire with closure of the browser       

 Question5:
Which of the following variable declarations within a class is invalid in PHP5?


    a.     private $type = 'moderate';
    b.     internal $term =3;
    c.     public $amnt = '500';
    d.     protected $name = 'Quantas Private Limited';

 the answers is:
    d.     protected $name = 'Quantas Private Limited';       

 Question6:
Which of the following statements is not true with regard to abstract classes in php5?


    a.     Abstract classes are introduced in PHP5
    b.     A class with a single abstract method must be declared abstract
    c.     Abstract class can contain non abstract methods
    d.     Abstract method must have method definition and can have optional empty braces following it

 the answers is:
    d.     Abstract method must have method definition and can have optional empty braces following it
       

 Question7:
Which of the following pair have non-associative equal precedence?


    a.     +, -
    b.     ==, !=
    c.     <<, >>
    d.     &=, |=

 the answers is:
    d.     &=, |=       

 Question8:
You have two strings, which you want to concatenate.

$str1 = 'Have a  ';
$str2 = 'Nice Day';

The fastest way would be:


    a.     $str1.Concat($str2);
    b.     $str1.$str2;
    c.     "$str1$str2";
    d.     None of the above

 the answers is:
    d.     None of the above       

 Question9:
For the following code:

function Expenses()
{
function Salary()
{

}
function Loan()
{
function Balance()
{
}
}

}
?>

Which of the following sequence will run successfully?


    a.     Expenses();Salary();Loan();Balance();
    b.     Salary();Expenses();Loan();Balance();
    c.     Expenses();Salary();Balance();Loan();
    d.     Balance();Loan();Salary();Expenses();

 the answers is:
    b.     Salary();Expenses();Loan();Balance();       

 Question10:
Which of the following is not supported in PHP5?


    a.     Type Hinting
    b.     Reflection
    c.     Magic Methods
    d.     Multiple Inheritance
    e.     Object Cloning

 the answers is:
    d.     Multiple Inheritance       

 Question11:
How would you start a session?


    a.     session(start);
    b.     session();
    c.     session_start();
    d.     begin_sesion();

 the answers is:
    c.     session_start();       

 Question12:
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;
?>


    a.     Only first \n character will be recognised and new line will be inserted.
    b.     Last \n will not be recognised and only first two parts will come in new lines.
    c.     All the \n will work and text will be printed on respective new lines.
    d.     All will be printed on one line irrespective of the \n.

 the answers is:
    c.     All the \n will work and text will be printed on respective new lines.       

 Question13:
What will be the result of the following expression:
6+4 * 9-3


    a.     60
    b.     87
    c.     39
    d.     30

 the answers is:
    b.     87       

 Question14:
What is true regarding $a + $b where both of them are arrays?


    a.     Duplicated keys are NOT overwritten
    b.     $b is appended to $a
    c.     The + operator is overloaded
    d.     This produces a syntax error

 the answers is:
    b.     $b is appended to $a
       
 Question15:
Which of the following characters are taken care of by htmlspecialchars?


    a.     <
    b.     >
    c.     single quote
    d.     double quote
    e.     &
    f.     All of the above

 the answers is:
    b.     >       

 Question16:
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?


    a.     local
    b.     global
    c.     static
    d.     None of the above

 the answers is:
    c.     static

 Question17:
Which of the following multithreaded servers allow PHP as a plug-in?


    a.     Netscape FastTrack
    b.     Microsoft's Internet Information Server
    c.     O'Reilly's WebSite Pro
    d.     All of the above

 the answers is: 
    d.     All of the above      

 Question18:
Multiple select/load is possible with:


    a.     Checkbox
    b.     Select
    c.     File
    d.     All of the above

 the answers is:
    d.     All of the above       

 Question19:
Which of the following variable names are invalid?


    a.     $var_1
    b.     $var1
    c.     $var-1
    d.     $var/1
    e.     $v1

 the answers is:
    b.     $var1       

 Question20:
Which of the following are useful for method overloading?


    a.     __call,__get,__set
    b.     _get,_set,_load
    c.     __get,__set,__load
    d.     __overload

 the answers is:
    c.     __get,__set,__load       

 Question21:
What will be the output of the following code?

function fn(&$var)
{
   $var = $var - ($var/10 * 5);
   return $var;
}
echo fn(100);


    a.     100
    b.     50
    c.     98
    d.     Error message
    e.     None of the above

 the answers is:       

 Question22:
    e.     None of the above
Which of the following type cast is not correct?

1 2 $fig = 23;
3 $varbl = (real) $fig;
4 $varb2 = (double) $fig;
5 $varb3 = (decimal) $fig;
6 $varb4 = (bool) $fig;
7 ?>


    a.     real
    b.     double
    c.     decimal
    d.     boolean

 the answers is:
    b.     double       

 Question23:
What will be the output of following code?

$a = 10;
echo "Value of a = $a";


    a.     Value of a = 10
    b.     Value of a = $a
    c.     Undefined
    d.     Syntax Error

 the answers is:
    b.     Value of a = $a       

 Question24:
What will be the output of the following code?

$var = 10;
function fn()
{
   $var = 20;
   return $var;
}
fn();
echo $var;


    a.     10
    b.     20
    c.     Undefined Variable
    d.     Syntax Error

 the answers is:
    d.     Syntax Error       

 Question25:
Which of the following attribute is needed for file upload via form?


    a.     enctype="multipart/form-data"
    b.     enctype="singlepart/data"
    c.     enctype="file"
    d.     enctype="form-data/file"

 the answers is:
    b.     enctype="singlepart/data"       

 Question26:
Which of the following is not a file related function in PHP?


    a.     fclose
    b.     fopen
    c.     fwrite
    d.     fgets
    e.     fappend

 the answers is:
    d.     fgets       

 Question27:
Which of the following is correct with regard to echo and print ?


    a.     echo is a construct and print is a function
    b.     echo is a function and print is a construct
    c.     Both are functions
    d.     Both are constructs

 the answers is:
    b.     echo is a function and print is a construct       

 Question28:
Which of the following is a correct declaration?


    a.     static $varb = array(1,'val',3);
    b.     static $varb = 1+(2*90);
    c.     static $varb = sqrt(81);
    d.     static $varb = new Object;

 the answers is:
    d.     static $varb = new Object;       

 Question29:
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?


    a.     I is correct and II is wrong
    b.     I is wrong and II is correct
    c.     Both I & II are wrong
    d.     Both I & II are correct

 the answers is:
    b.     I is wrong and II is correct
       
 Question30:
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 or false?


    a.     True
    b.     False

 the answers is:
    a.     True       

 Question31:
Which of the following text manipulation functions is supported by PHP?


    a.     strtoupper()
    b.     ucfirst()
    c.     strtolower()
    d.     str_split()
    e.     All of the above

the answers is:
    e.     All of the above       

 Question32:
Does PHP 5 support exceptions?


    a.     Yes
    b.     No

 the answers is:
    a.     Yes       

 Question33:
Which of the following is not a predefined constant?


    a.     TRUE
    b.     FALSE
    c.     NULL
    d.     __FILE__
    e.     CONSTANT

 the answers is:
    d.     __FILE__

 Question34:
Variable/functions in PHP don't work directly with:


    a.     echo()
    b.     isset()
    c.     print()
    d.     All of the above

 the answers is:
    b.     isset()       

 Question35:
Which of the following is used to maintain the value of a variable over different pages?


    a.     static
    b.     global
    c.     session_register()
    d.     None of the above

 the answers is:
    c.     session_register()       

 Question36:
Which of the following statements is incorrect with regard to interfaces?


    a.     A class can implement multiple interfaces
    b.     An abstract class cannot implement multiple interfaces
    c.     An interface can extend multiple interfaces
    d.     Methods with same name, arguments, and sequence can exist in the different interfaces implemented by a class

 the answers is:
    d.     Methods with same name, arguments, and sequence can exist in the different interfaces implemented by a class       

 Question37:
What is the output of the following code?


function
vec_add (&$a, $b)
{
    $a['x'] += $b['x'];
    $a['y'] += $b['y'];
    $a['z'] += $b['z'];
}

$a = array (x => 3, y => 2, z => 5);
$b = array (x => 9, y => 3, z => -7);

vec_add (&$a, $b);

print_r ($a);

?>


    a.     Array
(
    [x] => 9
    [y] => 3
    [z] => -7
)
    b.     Array
(
    [x] => 3
    [y] => 2
    [z] => 5
)
    c.     Array
(
    [x] => 12
    [y] => 5
    [z] => -2
)
    d.     Error
    e.     None of the above

the answers is:       

 Question38:
Which of the following statement is not correct for PHP?


    a.     It is a server side scripting language
    b.     A php file may contain text, html tags or scripts
    c.     It can run on windows and Linux systems only
    d.     It is compatible with most of the common servers used today

 the answers is:
    b.     A php file may contain text, html tags or scripts       

 Question39:
Does PHP provide the goto keyword in latest version?


    a.     Yes
    b.     No

 the answers is:
    b.     No       

 Question40:
What will be the output of the following code?

$Rent = 250;
function Expenses($Other)
{
   $Rent = 250 + $Other;
   return $Rent;
}
Expenses(50);
echo $Rent;


    a.     300
    b.     250
    c.     200
    d.     Program will not compile

 the answers is:
    c.     200

          Source

2 التعليقات

somebody said... @ August 3, 2012 at 12:38 PM

the very first answere is wrong..

that scares me for even looking further..

why should i even try them

Unknown said... @ August 20, 2012 at 4:14 AM

Hello Sir,

Please can you help and recheck the correct answers by sharing with someone else, so that some of the incorrect answers can be corrected.

Thanks

Post a Comment

Pulpit rock