Sunday 9 November 2014

oDesk php 5 test answers late$t



oDesk php 5 test answers 100% correct test answers

Are you introduce yourself as a web developer on odsk or any other freelancing marketplace . Are you think you are skilled on php and wont to work as a php developer ? then you need to pass odesk php 5 test . Because 70%+ client hire a freelancer base on his test performance on odesk . So to help you here we give you 100% correct oDesk php 5 test answers and we ensure you must pass in test .. 
odesk php 5 test answers

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


Question:
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(ANS)
                c.             Both I & II are wrong
                d.            Both I & II are correct

Question:
Which of the following variables is not related to file uploads?


                a.            max_file_size
                b.            max_execution_time(ANS)
                c.             post_max_size
                d.            max_input_time
Question:
What will be the result of the following expression:
6+4 * 9-3


                a.            60
                b.            87
                c.             39(ANS)
                d.            30

Question:
Which of the following is a Ternary Operator?


                a.            &
                b.            =
                c.             :?
                d.            ?:(ANS)
                e.            +=
                f.             &&

Question:
Which of the following is a PHP resource?


                a.            Domxml document
                b.            Odbc link
                c.             File(ANS)
                d.            All of the above

stion:
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
Question:
Which of the following are the valid PHP data types?


                a.            resource
                b.            null
                c.             boolean
                d.            string
                e.            Both a and c
                f.             Both b, c and d(ANS)
                g.            All of the above

stion:
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(ANS)

Question:
How would you store order number (34) in an 'OrderCookie'?


                a.            setcookie("OrderCookie",34);(ANS)
                b.            makeCookie("OrderCookie",34);
                c.             Cookie("OrderCookie",34);
                d.            OrderCookie(34);

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

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


                a.            10(ANS)
                b.            20
                c.             Undefined Variable
                d.            Syntax Error

Question:
Which of the following regular expressions can be used to check the validity of an e-mail addresss?


                a.            ^[^@ ]+@[^@ ]+\.[^@ ]+$(ANS)
                b.            ^[^@ ]+@[^@ ]+.[^@ ]+$
                c.             $[^@ ]+@[^@ ]+\.[^@ ]+^
                d.            $[^@ ]+@[^@ ]+.[^@ ]+^

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


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

Question:
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(ANS)

Question:
You need to keep an eye on the existing number of objects of a given class without introducing a non-class member variable. Which of the following makes this happen?


                a.            Add a member variable that gets incremented in the default constructor and decremented in the destructor 
                b.            Add a local variable that gets incremented in each constructor and decremented in the destructor
                c.             Add a static member variable that gets incremented in each constructor and decremented in the destructor(ANS)
                d.            This cannot be accomplished since the creation of objects is being done dynamically via "new." 

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


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

Question:
Which of the following is not true regarding XForms?


                a.            PHP provides support for XForm(ANS)
                b.            It can be used on PDF documents
                c.             The data is sent in XML format
                d.            The action and method parameters are defined in the body

Question:
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

Question:
Which of the following type cast is not correct?

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


                a.            real(ANS)
                b.            double
                c.             decimal
                d.            Boolean

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

<?php
var_dump (3*4);
?>


                a.            int(3*4)
                b.            int(12)(ANS)
                c.             3*4
                d.            12
                e.            None of the above

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


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

Question:
We have two variable definitions:

 1. 023
 2. x23

 Choose the correct options:


                a.            1 is octal
                b.            2 is hexadecimal
                c.             2 is octal
                d.            1 is hexadecimal
ANS:A,B,D

Question:
In your PHP application you need to open a file. You want the application to issue a warning and continue execution, in case the file is not found. The ideal function to be used is:


                a.            include()(ANS)
                b.            require()
                c.             nowarn()
                d.            getFile(false)

Question:
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(ANS)
Question:
Which of the following is not supported in PHP5?


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

Question:
What do you infer from the following code?

 <?php
         $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.(ANS)
Question:
For the following code:

 <?php
 function Expenses()
 {
 function Salary()
 {

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

 }
 ?>

 Which of the following sequence will run successfully?


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

Question:
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(ANS)

Question:
You have a 2D array in PHP:

$array = array(array(141,151,161), 2, 3, array(101, 202, 303));

You want to display all the values in the array. The correct way is:


                a.            function DisplayArray($array) {
    foreach ($array as $value) {
        if (array_valid($value)) {
            DisplayArray($value);
        } else {
            echo $value . "<br>";
        }
    }
}

DisplayArray($array);
                b.            function DisplayArray($array) {
    for ($array as $value) {
        if (valid_array($value)) {
            DisplayArray($value);
        } else {
            echo $value . "<br>";
        }
    }
}

DisplayArray($array);
                c.             function DisplayArray($array) {
    for ($array as $value) {
        if (is_array($value)) {
            DisplayArray($value);
        } else {
            echo $value . "<br>";
        }
    }
}

DisplayArray($array);
                (ANS)d.                function DisplayArray($array) {
    foreach ($array as $value) {
        if (is_array($value)) {
            DisplayArray($value);
        } else {
            echo $value . "<br>";
        }
    }
}

DisplayArray($array);

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


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

Question:
What is the output of the following code?

<?php

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(ANS)
                e.            None of the above

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


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

Question:
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(ANS)
                c.             static
                d.            None of the above

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

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

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


                a.            Correct category!(ANS)
                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

Question:
Which of the following printing construct/function accepts multiple parameters?


                a.            echo
                b.            print
                c.             printf
                d.            All of the above
ANS: A & C

Question:
You need to check the size of a file in PHP function.

 $size=X(filename);

 Which function will suitably replace 'X'?


                a.            filesize(ANS)
                b.            size
                c.             sizeofFile
                d.            getSize

Question:
Which of the following variable names are invalid?


                a.            $var_1
                b.            $var1
                c.             $var-1
                d.            $var/1
                e.            $v1
ANS: C & D

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


                a.            fclose
                b.            fopen
                c.             fwrite
                d.            fgets
                e.            fappend(ANS)
Question:
Variable/functions in PHP don't work directly with:


                a.            echo()(ANS)
                b.            isset()
                c.             print()
                d.            All of the above
Question:
Which of the following variable declarations within a class is invalid in PHP5?


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

Question: What will be the output of the following code?
function fn(&$var) {
   $var = $var - ($var/l0*5);
   return $var;
)
echo fn(100);
a.100
b. 50
c. 98
d. Error message
e. None of the above


MORE ANSWER IS HERE: http://portal.bezkorovayny.com/2011/12/test-results-odesk-php5-test/

Question: Which of the following is not a valid PHP parser tag?

a. script
b. ?p
c. %
d. ?php

Question (many answers); Which of the the following are PHP file upload related functions?

a. upload_file()
b. is_uploaded_file()
c. move_uploaded_file()
d. Noneoftheabove

Question: Multiple select/load is possible with:

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

Question: 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

Question: Consider the following class:

1 class Insurance
2 {
3 function clsName()
4 {
5 echo get_class($this);
6 }
7 }
8 $cl = new Insurance();
9 Scl->clsName();
10 lnsurance::clsName();
Which of the following Lines should be commented to print the class name without errors?
a. Line 8 and 9
b. Line 10
c. Line 9 and 10
d. All the three lines 8,9, and 10 should be left as it is.

No comments:

Post a Comment