The On Demand Global Workforce - oDesk

Wednesday, November 3, 2010

PHP Test And solutions oDesk

PHP Test And solutions
Question.11.

which of the following are used for code reuse?

a. Loops
b. functions
c. Database
d. include files


Solution:

B,D

Question.13.

which of the following is the corect 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") {.........}

Solution:

Question.14.

Which of the following are ''magic constant'?

a. __LINE__
b. __FILE__
c __PRETTY_FUNCTION__
d __CLASS__
e. __METHOD__

Solution:

Question.15.

you have defined three variables $to, $subject, and $body to send an email. Which of the following methods would you use for sending an email?

a. mail($to, $subject,$body)
b. sendmail($to, $subject,$body)
c. mail(to, subject,body)
d. sendmail(to, subject,body)

Solution:

Question.16.

Which one of the following is turnary operator?

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

Solution

D

Question.17.

What is the result of the following Exprssion?
5+2*4+6

a. 70
b. 19
c. 34
d. 21

Solution:
B

Question.18.

The default value of register global in PHP is:

a. Off
b. On

Solution:

A

Question.19.


What would b the outpur of the following code?

$string = 'good day';
$string = ucword($string);
echo $string;
?>

a. good day
b. GOOD DAY
c. Good Day
d. non of the above

Solution:

C

Question.20.

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){}

Solution:

D

oDesk Question Answers

Question.21.

What will be the output of the following code?

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

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

Solution:

A

Question.22.

Which of the following regualr expressions can be used to check the validity of an email address?

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

Solution:

Question.23.

Which of the following is not represent logical AND operator in PHP?
a. &
b. &&
c. And
d. AND

Solution:
A

Question.24.

Which of the following are file PHP file Upload Related function?

a. upload_file()
b. is_upload_file()
c. move_upload_file()
d. Non of the above

Solution:

D

Question.25.

Does PHP support exceptions?

a. Yes
b. No

Solution:

A

Question.26.

Which of the following functions do you need to implement HTTP Basic Authentication?

a. Authenticate()
b. header()
c. basic_auth()
d. Non of the above

Solution:

D

Question.27.

What will be the output of the following code?

for ($i = 0; $i <>
{if($i == 2)
continoue;
print "$i\n";
}
?>

a. 0
1
2
3
4
5
b. 0
1
2
3
4
c. 2
d. 0
1
2
4
e. non of the above

Solution:

B

Question.28.

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 concatienation operator(.)

Solution:

Question.29.

Which of the following is not supported in PHP5?

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

Solution:

Question.30.

Which of the following are valid PHPdata types?

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

Solution:

oDesk HTML Tests and Solutions Answers

HTML Tests and Solutions
Q.NO.11.

Which of the following value for the scrolling atribute from the fram tag is not valid?

a. yes
b. default
c. auto
d. no

Q.NO.12.

One of your Web pages named Listing.html you specified a target like this:

Old Listing


How will you make a link to the above target?

a. Check Old Listing as well

b. Check Old Listing as well

b. Check Old Listing as well

b. Check Old Listing as well

Q.NO.13.

While designing the links page of your website. You want the link to open in a new browser window.
How will you implement this with HTML?

a.Mailer
b. Mailer
c. Mailer
d. Mailer

Q.NO.14.

You are creating several web pages for a website that contains several rather large data tables.
Many of which are some what sismilar in the number of columns, rows and other common table formating. In addition ,CSS
will be employed for formating the tables. Which one of the following types of CSS has the highest priority over the others
and typically require the greatest total amount of code space for the entire website for formtting the various table cells

a. External Style Sheet
b. Inline Style Sheet
c. Internal Style Sheet
d. Browser default

Q.NO.15.

Choose the incorrect statment.

a. The tag emphasizes the given text by italiczing.
b. The tag indicates that the text inside is an example of typed code.
c. The tag indicates that the text inside the tag has been revised
d. The tag strongly emphasizing the text

Q.NO.16.

The tag is used to pass the parametrs to an applet is:

a. appletpar
b. applet
c. param
d. var

Q.NO.17.

Within a table cell


a.

tag can't be used
b.
    tag can't be used
    c.
    tag can't be used
    d.
    tag can't be used
    e. All the above tags could be used


    Q.NO.18.

    The use of depricated align atribute with an image tag result in :

    a. Text taht is aligned with the bottom of the image if the value of align is bottom.
    b. Text that is aligned with the top of the value of align is top.
    c. Text that is located to the left of the image if the value of align is left.
    d. Text that is located to the right of the image if the value of align is right.

    Q.NO.19

    Which of the folowing atributes is/are valid for a select tag.

    a. name
    b. size
    c. multiple
    d. all of the above

    Q.NO.20.

    Which form event is fired on the click of a button tag with its type atribute value equal to submit.

    a. onload
    b. onsubmit
    c. onload
    d. onreset

    oDesk Readiness test answers

    oDesk Readiness test answers


    Q no 1: If you have not done so please download and install the oDesk Team application. With the client running right click on the oDesk Team icon in the system tray (or doc for Mac users). Which of the following options is listed first? Note that you do NOT have to log into any actual Team Room to answer this question.

    A: TeamRoom..


    Q 2: Which of the following actions are NOT allowed when applying to job openings?

    A: All of the above

    Q:3 'How does feedback work on oDesk?'

    A: All of the above


    Q4: Which of the following break the oDesk user agreement?

    A: All of the above

    Q5: Which of the following is true of your oDesk timelog?

    A: All of the above

    Q6: Which of the following statements about the oDesk Team application are true?

    A: All of the above

    Q7: What do you need to do to ensure guaranteed payment on hourly jobs?

    A: All of the above


    Q8: Which of the following statements are correct about oDesk fees?

    A: All of the above

    Q9: Buyers set weekly limits on hourly assignments, how do these work?

    A: All of the above

    Q10: How does oDesk's dispute resolution policy for work?

    A: All of the above


    Q11: Can I start my own company on oDesk?

    A: Yes! oDesk allows you to build and manage a team of workers, colleagues and collaborators. You can even subcontract other workers on oDesk to other customers oDesk (and take a cut).

    odesk javascript solution

    odesk javascript solution
    JavaScript Test Solution

    1. What’s relationship between JavaScript and ECMAScript? -
    ECMAScript is yet another name for JavaScript (other names include LiveScript).
    The current JavaScript that you see supported in browsers is ECMAScript revision 3.
    2. What are JavaScript types? -
    Number, String, Boolean, Function, Object, Null, Undefined.
    3. How do you convert numbers between different bases in JavaScript? -
    Use the parseInt() function, that takes a string as the first parameter, and the base as
    a second parameter. So to convert hexadecimal 3F to decimal, use parseInt ("3F", 16);
    4. What does isNaN function do? -
    Return true if the argument is not a number.
    5. What is negative infinity? -
    It’s a number in JavaScript, derived by dividing negative number by zero.

    6. What boolean operators does JavaScript support? -
    &&, || and !
    7. What does "1"+2+4 evaluate to? -
    Since 1 is a string, everything is a string, so the result is 124.
    8. How about 2+5+"8"? -
    Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation,
    so 78 is the result.
    9. What looping structures are there in JavaScript? -
    for, while, do-while loops, but no foreach.
    10. How do you create a new object in JavaScript? -
    var obj = new Object(); or var obj = {};
    11. How do you assign object properties? -
    obj["age"] = 17 or obj.age = 17.
    12. What’s a way to append a value to an array? -
    arr[arr.length] = value;
    13. What is this keyword? -
    It refers to the current object.

    odesk javascript solution

    odesk javascript solution
    JavaScript Test Solution

    1. What’s relationship between JavaScript and ECMAScript? -
    ECMAScript is yet another name for JavaScript (other names include LiveScript).
    The current JavaScript that you see supported in browsers is ECMAScript revision 3.
    2. What are JavaScript types? -
    Number, String, Boolean, Function, Object, Null, Undefined.
    3. How do you convert numbers between different bases in JavaScript? -
    Use the parseInt() function, that takes a string as the first parameter, and the base as
    a second parameter. So to convert hexadecimal 3F to decimal, use parseInt ("3F", 16);
    4. What does isNaN function do? -
    Return true if the argument is not a number.
    5. What is negative infinity? -
    It’s a number in JavaScript, derived by dividing negative number by zero.

    6. What boolean operators does JavaScript support? -
    &&, || and !
    7. What does "1"+2+4 evaluate to? -
    Since 1 is a string, everything is a string, so the result is 124.
    8. How about 2+5+"8"? -
    Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation,
    so 78 is the result.
    9. What looping structures are there in JavaScript? -
    for, while, do-while loops, but no foreach.
    10. How do you create a new object in JavaScript? -
    var obj = new Object(); or var obj = {};
    11. How do you assign object properties? -
    obj["age"] = 17 or obj.age = 17.
    12. What’s a way to append a value to an array? -
    arr[arr.length] = value;
    13. What is this keyword? -
    It refers to the current object.

    PHP interview questions and answers

    PHP interview questions and answers
    1. What does a special set of tags do in PHP?
    The output is displayed directly to the browser.
    2. What the difference is between include and require?
    It is how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
    3. I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?
    PHP Interpreter treats numbers beginning with 0 as octal. Look at the similar PHP interview questions for more numeric problems.
    4. Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example?
    In this example it wouldn’t matter, since the variable is all by itself, but if you were to print something like "{$a},000,000 mln dollars", then you definitely need to use the braces.
    5. How do you define a constant?
    Via define() directive, like
    define ("MYCONSTANT", 100);
    6. How do you pass a variable by value?
    Just like in C++, put an ampersand in front of it, like $a = &$b
    7. Will comparison of string "10" and integer 11 work in PHP?
    Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.
    8. When are you supposed to use endif to end the conditional statement? - When the original if was followed by : and then the code block without braces.
    9. Explain the ternary conditional operator in PHP? –
    Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.
    10. How do I find out the number of parameters passed into function? func_num_args() function returns the number of parameters passed in.
    11. If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b?
    100, it’s a reference to existing variable.
    12. What’s the difference between accessing a class method via -> and via ::?
    :: is allowed to access methods that can perform static operations, i.e. those, which do not require object initialization.
    13. Are objects passed by value or by reference?
    Everything is passed by value.
    14. How do you call a constructor for a parent class?
    parent::constructor($value)

    15. What’s the special meaning of __sleep and __wakeup?
    __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.
    16. Why doesn’t the following code print the newline properly?
    Because inside the single quotes the n character is not interpreted as newline, just as a sequence of two characters - and n.

    17. Would you initialize your strings with single quotes or double quotes? Since the data inside the single-quoted string is not parsed for variable substitution, it’s always a better idea speed-wise to initialize a string with single quotes, unless you specifically need variable substitution.
    18. How come the code works, but doesn’t for two-dimensional array of mine?
    Any time you have an array with more than one dimension, complex parsing syntax is required. print "Contents: {$arr[1][2]}" would’ve worked.
    19. What is the difference between characters 23 and x23?
    The first one is octal 23, the second is hex 23.
    20. With a heredoc syntax, do I get variable substitution inside the heredoc contents?
    Yes.
    21. I want to combine two variables together:
    22. $var1 = 'Welcome to ';
    23. $var2 = 'TechInterviews.com';
    What will work faster? Code sample 1:
    $var 3 = $var1.$var2;
    Or code sample 2:
    $var3 = "$var1$var2";
    Both examples would provide the same result - $var3 equal to "Welcome to TechInterviews.com". However, Code Sample 1 will work significantly faster. Try it out with large sets of data (or via concatenating small sets a million times or so), and you will see that concatenation works significantly faster than variable substitution.
    24. For printing out strings, there are echo, print and printf. Explain the differences. –
    echo is the most primitive of them, and just outputs the contents following the construct to the screen. print is also a construct (so parentheses are optional when calling it), but it returns TRUE on successful output and FALSE if it was unable to print out the string. However, you can pass multiple parameters to echo, like:

    and it will output the string "Welcome to TechInterviews!" print does not take multiple parameters. It is also generally argued that echo is faster, but usually the speed advantage is negligible, and might not be there for future versions of PHP. printf is a function, not a construct, and allows such advantages as formatted output, but it’s the slowest way to print out data out of echo, print and printf.
    25. I am writing an application in PHP that outputs a printable version of driving directions. It contains some long sentences, and I am a neat freak, and would like to make sure that no line exceeds 50 characters. How do I accomplish that with PHP? –
    On large strings that need to be formatted according to some length specifications, use wordwrap() or chunk_split().
    26. What’s the output of the ucwords function in this example?
    27. $formatted = ucwords("TECHINTERVIEWS IS COLLECTION OF INTERVIEW QUESTIONS");
    print $formatted;
    What will be printed is TECHINTERVIEWS IS COLLECTION OF INTERVIEW QUESTIONS.
    ucwords() makes every first letter of every word capital, but it does not lower-case anything else. To avoid this, and get a properly formatted string, it’s worth using strtolower() first.
    28. What’s the difference between htmlentities() and htmlspecialchars()? - htmlspecialchars only takes care of <, >, single quote ‘, double quote " and ampersand.
    htmlentities translates all occurrences of character sequences that have different meaning in HTML.
    29. What’s the difference between md5(), crc32() and sha1() crypto on PHP? - The major difference is the length of the hash generated. CRC32 is, evidently, 32 bits, while sha1() returns a 128 bit value, and md5() returns a 160 bit value. This is important when avoiding collisions.
    30. So if md5() generates the most secure hash, why would you ever use the less secure crc32() and sha1()?
    Crypto usage in PHP is simple, but that doesn’t mean it’s free. First off, depending on the data that you’re encrypting, you might have reasons to store a 32-bit value in the database instead of the 160-bit value to save on space. Second, the more secure the crypto is, the longer is the computation time to deliver the hash value. A high volume site might be significantly slowed down, if frequent md5() generation is required.
    31. How do you match the character ^ at the beginning of the string? –