Tuesday 19 February 2013

oDESK PHP5 Test Answers

updated 20th feb 2013

Hello and Welcome. Sadly php5 test questions updated by oDESK but don't worry we also UPDATED our answers

 

 

 

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

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

a. +,-
b. ==,!=
C. «,»
d. &=,|=

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

a. max_file_size
b. max_execution_time
c. post_max_size
d. max_input_time

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. “&ltbr>”;
      }
   }
} 

DisplayArray($array);
d.
function DisplayArray($array) {
   foreach ($array as $value) {
      if (is_array($value)) {
         DisplayArray($value);
      } else {
         echo $value “&ltbr>”;
      }
   }
}

DisplayArray($array);
Right answer: d.

Question: Multiple select/load is possible with:

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

Question: The following php variables are declared:

$company = ‘ABS Ltd’;
$$company =‘, Sydney’;
Which of the following is not a correct way of printing ‘ABS Ltd. Sydney’?
a. echo “$company $$company”;
b. echo “$company ${$company}”;
c. echo “$company ${‘ABS Ltd‘}“;
d. echo “$company {$$company}”;

Question (many answers)

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

Question: Which of the following is a predefined constant?

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

Question (many answers): Which of the following variable names are invalid?

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

Question (many answers): Which of the following are not considered as boolean False?

a. FALSE
b. 0
c. “0”
d. “FALSE”
e. 1
f. NULL

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

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

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

$fig=23;
$varbl= (real) $fig;
$varb2 = (double) $flg;
$varb3 = (decimal) $flg;
$varb4 = (bool) $fig;
a. real
b. double
c. decimal
d. boolean

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

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

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

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

$a = 10;
if($a > 5 OR < 15)
echo “true”;
else
echo “false”
a. true
b. false
c. No output
d. Parse Error

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
c. Cookie will expire with within 30 minutes
d. Cookie will expire in 24 hours

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

$size=X(filename);
Which function will suitably replace ‘X’ ?
a. filesize
b. size
c. sizeofFile
d. getSize

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

Question: Which of the following is a correct declaration?

a. static $varb = array(1 ,‘var, 3);
b. static $varb = 1+(2*9O);
c. static $varb = sqrt(81);
d. static $varb = new Object;

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!
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: If visibility is not defined for a method/member then it is treated as public static.

a. True
b. False

Question (many answers): 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 interlaces
c. An interlace can extend multiple interfaces
d. Methods with same name, arguments, and sequence can exist in the different interlaces implemented by a class

Question: Which of the following is a Ternary Operator?

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

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 c and d
g. All of the above

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

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

Question: What will be the result of the following expression:

6+4 * 9-3
a. 60
b. 87
c. 39
d. 30

Question: Does php 5 support exceptions?

a. Yes
b. No

Question (many answers): Which of the following printing construct/function accepts multiple parameters?

a. echo
b. print
c. printf
d. Allof the above

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

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

a. PHP provides support for XForm
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: How would you start a session?

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

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

a. setcookie(«OrderCookie”, 34);
b. makeCookie(”OrderCookie”, 34);
c. Cookie(«OrderCookie”, 34);
d. OrderCookie(34);

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

Question: What will be the result of following operation?

print 4 << 5;
a. 3
b. 128
c. 120
d. 6

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

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

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

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

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: 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
d. This cannot be accomplished since the creation of objects is being done dynamically via “new”

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. Allof the above

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

a. static
b. global
c. session_register()
d. Noneoftheabove

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

Question: Consider the following two statements:

1 while (expr) statement
2 while (expr): statement endwhile;
Which of the following are true in context of the given statements?
a. 1 is correct and 2 is wrong
b. 1 is wrong and 2 is correct
c. Both 1 & 2 are wrong
d. Both 1 & 2 are correct

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

Question: What is the output of the following code?

function vec_add (&Sa, Sb) {
   $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
[xJ =>12
[yJ => 5
[z] => -2
d. Error
e. None of the above

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()
b. require()
c. nowarn()
d. getFile(false)

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: Which of the following attribute is needed for file upload via form?

a. enctype=”multipart/formdata”
b. enctype=”singlepart/data’
c. enctype=»file”
d. enctype=»form-data/file”

Question: Variable/functions in PHP don’t work directly with:

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

Question: Which of the following is a PHP resource?

a. Domxml document
b. Odbc link
c. File
d. Allot the above

Question: The inbuilt function to get the number of parameters passed is:

a. arg_num()
b. func_args_count()
c. func_num_args()
d. None of the above

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

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

echo 30 * 5.7
a. 150.7
b. 1507
c. 171
d. you can’t concatenate integers
e. error will occur

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

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

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

Question: Which of the following variables are supported by ‘str_replace’ function?

a. Integer
b. String
c. Boolean
d. Array

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

a. _call,_get,_set
b. _get,_set,_load
c. _get,_set,_isset
d. _overload

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

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

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

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.

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

Question: Which of the following functions output text?

a. echo()
b. print()
c. println()
d. display()

Question: Which of the following crypto ¡n PHP returns longest hash value?

a. md5()
b. shalo
c. crc32()
d. All return same length hash

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
c. static
d. None of the above

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

a. Yes
b. No

Monday 30 July 2012

English Vocabulary Test (U.S. Version)

Question: Choose the word or phrase that is most nearly an antonym of the word below.
MITIGATE
c. Intensify

 Question: Choose the word that best corresponds with the definition given below.
v. To impose with authority; urge strongly
 a. Enjoin

 Question: Choose the word that best corresponds with the definition given below.
v. To issue a vehement verbal attack; to denounce explosively
c. Fulminate

 Question: Complete the following sentence by choosing the correct set of words from the options below.
It's a good thing you're so________ at paperwork, because you'll need to fill out hundreds of forms to________ a child.
c. adapt/adopt

Question: Choose the word that best corresponds with the definition given below.
n. Flair; style; a flamboyant manner
c. Resonance

 Question: Choose the definition that best reflects the meaning of the word in CAPITAL LETTERS as it is used in the sentence below.
The mysterious message Claude received could be a HARBINGER of what's in store for him and his family.
b. Omen; forerunner

Question: Choose the word or phrase that is most nearly a synonym for the word in CAPITAL LETTERS in the following sentence.
Roger might be more AMENABLE to your ideas if you presented them without sneering.
 b. Willing to accept

Question: Choose the word or phrase that is most nearly a synonym for the word in CAPITAL LETTERS in the following sentence.
The coach was absolutely disgusted by his team's INDOLENCE and nasty attitude. wizened
 c. Laziness

Question: Choose the word or phrase that is most nearly an antonym of the word below.
REFUTE
b. Support

Question: Choose the word or phrase that is most nearly an antonym of the word below. deleterious
INORDINATE
a. Reasonable

11. Question: Complete the following sentence by choosing the correct homophone from the options below.
Oscar, who did not possess a discerning_________ , preferred hot dogs to steak.
b. pallet

 Question: Choose the definition that best reflects the meaning of the word in CAPITAL LETTERS as it is used in the sentence below.
The journalist denied that he had any PRURIENT interest in the politician's private life, but his titillating articles seemed to indicate otherwise.
 b. Overly curious about the sexual behavior of others

 Question: Choose the word that best corresponds with the definition given below.
adj. Tending to create ill will or give offense
 b. Invidious

Question: Complete the following sentence by choosing the correct set of words from the options below.
I can_________ all the terms of the apartment lease_________ the one about not allowing pets.
 d. accept/except

 Question: Choose the definition that best reflects the meaning of the word in CAPITAL LETTERS as it is used in the sentence below.
The recent shenanigans in the town square went against all PRECEPTS of decency.
 a. Rules for action or behavior

Question: Choose the word or phrase that is most nearly an antonym of the word below. adverse
ITINERANT
 a. Permanent

 Question: Complete the following sentence by choosing the correct homophone from the options below.
The company is__________ committed to developing educational television programs for children.
 c. wholly

Question: Complete the following sentence by choosing the correct set of homophones from the options below.
The_________ poet, knowing his death was__________ , struggled to finish his final ode.
d. eminent/imminent

Question: Complete the following sentence by choosing the correct set of homophones from the options below.
Rachel knew that she'd soon be living in______________ circumstances unless she got her financial problems________________ out
immediately.
 b. straitened/straightened

Question: Choose the definition that best reflects the meaning of the word in CAPITAL LETTERS as it is used in the sentence below.
The plots of all her novels just seem to MEANDER along, to the point where I can't follow the storyline or figure out who's who.
 a. Purposely confuse

21. Question: Complete the following sentence by choosing the correct word from the options below.
The only________________ difference between the twins is the shape of their noses.
 b. distinguished

Question: Choose the definition that best reflects the meaning of the word in CAPITAL LETTERS as it is used in the sentence below.
Now that the festivities have ended, perhaps we can return to some SEMBLANCE of normality.
 c. Outward appearance

Question: Choose the word that best corresponds with the definition given below.
adj. Narrow-minded; limited in scop
 d. Sectarian

Question: Complete the following sentence by choosing the correct homophone from the options below.
That grueling competition really tested the____________ of the gymnastics team.
 b. metal

Question: Choose the word that best corresponds with the definition given below.
Capacity for producing a desired result; effectiveness
 d. Efficacy

Question: Complete the following sentence by choosing the correct set of words from the options below.
Although_________ wanted to keep the boat all to_________ , I knew it would be used extensively by both Susan and________________ .
 d. I/myself/me

 Question: Choose the definition that best reflects the meaning of the word in CAPITAL LETTERS as it is used in the sentence below.
Poverty is RIFE in the rural areas of our county, where one in three families receives some state assistance. RIFE
a. Prevalent

Question: Choose the definition that best reflects the meaning of the word in CAPITAL LETTERS as it is used in the sentence below.
The exchange student was disheartened by the rather BRUSQUE welcome she received from her host family.
c. Blunt or rude in manner of speech

Question: Complete the following sentence by choosing the correct set of words from the options below.
The workers were allowed to___________ down once they'd________ the brick, but the foreman himself has not yet_________
down.
 d. lay/laid/laid

 Question: Choose the word or phrase that is most nearly a synonym for the word in CAPITAL LETTERS in the following sentence.
Alec has always been CONTEMPTUOUS of his fellow writers.
 a. Disdainful

Question: Choose the definition that best reflects the meaning of the word in CAPITAL LETTERS as it is used in the sentence below.
Maude managed to sweep up the broken dishes without a word of REPROOF to her children.
 a. Expression of disapproval or blame
Expression of apology or regret

Question: Choose the definition that best reflects the meaning of the word in CAPITAL LETTERS as it is used in the sentence below.
The despot's MINIONS were only too eager to tout his edicts and report any unrest among his subjects.
 a- Sycophants; servile followers

 Question: Choose the word or phrase that is most nearly an antonym of the word below.
AVARICE
d. Generosity

Question: Complete the following sentence by choosing the correct word from the options below.
The crafty spy gave a___________ name to the hotel clerk.
 c. fictitious

 Question: Choose the word or phrase that is most nearly a synonym for the word in CAPITAL LETTERS in the following sentence.
The soldier's EXEMPLARY conduct did not go unnoticed by his sergeant.
Admirable

 Question: Choose the word or phrase that is most nearly a synonym for the word in CAPITAL LETTERS in the following sentence.
She always got a VICARIOUS thrill from watching her father skydive.
 d. Sickening

Question: Complete the following sentence by choosing the correct word from the options below.
The proposed after-school tutoring program promises_____________ benefits to the students and the community.
 a. innumerable

Question: Complete the following sentence by choosing the correct word from the options below.
I screamed as the monstrous presence snaked toward me on the dark and_________ path.
 b. tortuous

Question: Complete the following sentence by choosing the correct homophone from the options below.
We all remarked on how well the spray of begonias____________ her hair color.
 a. complimented

 Question: Complete the following sentence by choosing the correct set of words from the options below.
She hastened to_________ me that she intends to pay the bill, and that she will_________ that the check is mailed today.
 a. assure/ensure

Question: Choose the word or phrase that is most nearly a synonym for the word in CAPITAL LETTERS in the following sentence.
The soldier's EXEMPLARY conduct did not go unnoticed by his sergeant.
 c. Admirable

 Question: Choose the word or phrase that is most nearly a synonym for the word in CAPITAL LETTERS in the following sentence.
His son's group of friends had a DELETERIOUS effect on his schoolwork.
d. Harmful

Question: Choose the definition that best reflects the meaning of the word in CAPITAL LETTERS as it is used in the sentence below.
It would BEHOOVE you to show a little more respect to the judge and jury who are deciding your case.
c. Be worthwhile or proper for; be incumbent upon

Question: Choose the definition that best reflects the meaning of the word in CAPITAL LETTERS as it is used in the sentence below.
Running around barefoot in the snow will only EXACERBATE your flu symptoms.
 b. Aggravate; worsen

 Question: Choose the word that best corresponds with the definition given below.
n. A mass or crowd; multitude
 c. Horde

Question: Choose the definition that best reflects the meaning of the word in CAPITAL LETTERS as it is used in the sentence below.
Dan was a nice guy, but he was far too GARRULOUS and tended to monopolize people at parties.
 c. Excessively talkative about trivial topics

Question: Choose the word that best corresponds with the definition given below.
adj. Similar to something else in certain respects, as in form, function, or meaning
c. Analogous

 Question: Choose the word that best corresponds with the definition given below.
adj. Hardhearted; unmoved by pity
 b. Parsimonious

 Question: Choose the word or phrase that is most nearly an antonym of the word below.
ADVERSE
 d. Twisted

 Question: Complete the following sentence by choosing the correct homophone from the options below.
Who has the power to_________ out justice to the citizens of this country?
 a. meet

Question: Choose the word that best corresponds with the definition given below.
adj. Easily provoked to anger; irritable
a. Sapid

52. Question: Choose the word that best corresponds with the definition given below.
n. Flair; style; a flamboyant manner
 c. Resonance

53. Question: Choose the word or phrase that is most nearly a synonym for the word in CAPITAL LETTERS in the following sentence.
Agatha RUMINATED for weeks about the consequences of telling Arthur about the affair.
a. Pondered

Question: Complete the following sentence by choosing the correct homophone from the options below.
This experiment was designed to __________ certain behaviors from the test subjects.
  a. illicit

Question: Choose the word or phrase that is most nearly a synonym for the word in CAPITAL LETTERS in the following sentence.
It seems we've reached an IMPASSE in our negotiations.
d. Stalemate

Question: Choose the word or phrase that is most nearly a synonym for the word in CAPITAL LETTERS in the following sentence.
The WIZENED old woman gave Jack a handful of beans and some good advice.
 b. Shriveled

Question: Choose the word that best corresponds with the definition given below.
n. A position that entails little work but provides a salary
d. Sinecure
Question: Complete the following sentence by choosing the correct set of words from the options below.
Mr. Winkle was dismayed to discover that his willful young wife________ her wealth and__________ the law at every
opportunity.
  c. flaunted/flouted

Question: Complete the following sentence by choosing the correct word from the options below.
She launched her new line of handbags________ a fanfare of publicity.
c. among

 Question: Choose the word that best corresponds with the definition given below.
n. Local or provincial dialect
b. Patois

Question: Choose the word or phrase that is most nearly a synonym for the word in CAPITAL LETTERS in the following sentence.
She entered the ballroom on the arm of a DEBONAIR young man.
  d. Charming and elegant

 Question: Complete the following sentence by choosing the correct word from the options below.
We expected the waiter to show us out of that snooty restaurant in a hurry, but he turned out to be quite jolly and ____
  c. complaisant