Wednesday, April 26, 2017

Upwork PHP Test Level I 2016

Upwork PHP Test 2016


1. What is the best practice for running MySQL queries in PHP? Consider the risk of SQL injection.
Answers:
a. Use mysql_query() and variables: for example: $input = $_POST[‘user_input’]; mysql_query(“INSERT INTO table (column) VALUES (‘” . $input . “‘)”);
b. Use PDO prepared statements and parameterized queries: for example: $input= $_POST[“user-input”] $stmt = $pdo->prepare(‘INSERT INTO table (column) VALUES (“:input”); $stmt->execute(array(‘:input’ => $input));
c. Use mysql_query() and string escaped variables: for example: $input= $_POST[“user-input”] $input_safe = mysql_real_escape_string($input); mysql_query(“INSERT INTO table (column) VALUES (‘” . $input. “‘)”);
d. Use mysql_query() and variables with a blacklisting check: for example: $blacklist = array(“DROP”,”INSERT”,”DELETE”); $input= $_POST[“user-input”] if (!$array_search($blacklist))) mysql_query(“INSERT INTO table (column) VALUES (‘” . $input. “‘)”);
2. Which of the following methods should be used for sending an email using the variables $to, $subject, and $body?
Answers:
a. mail($to,$subject,$body)
b. sendmail($to,$subject,$body)
c. mail(to,subject,body)
d. sendmail(to,subject,body)
3. Which of the following is used to maintain the value of a variable over different pages?
Answers:
a. static
b. global
c. session_register()
d. None of these
4. Which of the following will check if a function exists?
Answers:
a. function_exists()
b. has_function()
c. $a = “function to check”; if ($a ()) // then function exists
d. None of these
5. Which of the following is not a file-related function in PHP?
Answers:
a. fclose
b. fopen
c. fwrite
d. fgets
a. fappend
6. Which of the following is true about the singleton design pattern?
Answers:
a. A singleton pattern means that a class will only have a single method.
b. A singleton pattern means that a class can have only one instance object.
c. A singleton pattern means that a class has only a single member variable.
d. Singletons cannot be implemented in PHP.
7. Which of the following characters are taken care of by htmlspecialchars?
Answers:
a. < a. >
b. single quote
c. double quote
d. &
a. All of these
8. Which of the following will read an object into an array variable?
Answers:
a. $array_variable = get_object_vars($object);
b. $array_variable = (array)$object;
c. $array_variable = array $object;
d. $array_variable = get_object_vars $object;
9. Which of the following variable declarations within a class is invalid in PHP?
Answers:
a. private $type = ‘moderate’;
b. internal $term = 3;
c. public $amnt = ‘500’;
d. protected $name = ‘Quantas Private Limited’;
10. Which of the following is not a PHP magic constant?
Answers:
a. __FUNCTION__
b. __TIME__
c. __FILE__
d. __NAMESPACE__
e. __CLASS__
11. Which of the following will print out the PHP call stack?
Answers:
a. $e = new Exception; var_dump($e->debug());
b. $e = new Exception; var_dump($e->getTraceAsString());
c. $e = new Exception; var_dump($e->backtrace());
d. $e = new Exception; var_dump($e->getString());
12. What will be the output of the following code?

Answers:
a. int(3*4)
b. int(12)
c. 3*4
d. 12
e. None of the above
13. Which of the following is correct about Mysqli and PDO?
Answers:
a. Mysqli provides the procedural way to access the database while PDO provides the object oriented way.
b. Mysqli can only be used to access MySQL database while PDO can be used to access any DBMS.
c. MySQLi prevents SQL Injection whereas PDO does not.
d. MySQLi is used to create prepared statements whereas PDO is not.
14. What is the correct way to send a SMTP (Simple Mail Transfer Protocol) email using PHP?
Answers:
a. s.sendmail($EmailAddress, [$MessageBody], msg.as_string())
b. sendmail($EmailAddress, “Subject”, $MessageBody);
c. mail($EmailAddress, “Subject”, $MessageBody);
d. $MessageBody
15. Which of the following will start a session?
Answers:
a. session(start);
b. session();
c. session_start();
d. login_sesion();
16. For the following code:

Which of the following sequence will run successfully?
Answers:
a. Expenses();Salary();Loan();Balance();
b. Salary();Expenses();Loan();Balance();
c. Expenses();Salary();Balance();Loan();
d. Balance();Loan();Salary();Expenses();
17. What enctype is required for file uploads to work?
Answers:
a. multipart/form-data
b. multipart
c. file
d. application/octect-stream
e. None of these
18. Which of the following is incorrect with respect to separating PHP code and HTML?
Answers:
a. Use an MVC design pattern.
b. As PHP is a scripting language, HTML and PHP cannot be separated.
c. Use any PHP template engine e.g: smarty to keep the presentation separate from business logic.
d. Create one script containing your (PHP) logic outputting XML and one script produce the XSL to translate the XML to views.
19. Which one of the following is not an encryption method in PHP?
Answers:
a. crypt()
b. md5()
c. sha1()
d. bcrypt()
20. What function should you use to join array elements with a glue string?
Answers:
a. join_st
b. implode
c. connect
d. make_array
e. None of these
21. Which function can be used to delete a file?
Answers:
a. delete()
b. delete_file()
c. unlink()
d. fdelete()
e. file_unlink()
22. What is the string concatenation operator in PHP?
Answers:
a. +
b. ||
c. .
d. |||
e. None of these
23. Which of the following is useful for method overloading?
Answers:
a. __call,__get,__set
b. _get,_set,_load
c. __get,__set,__load
d. __overload
24. Which of the following will store order number (34) in an ‘OrderCookie’?
Answers:
a. setcookie(“OrderCookie”,34);
a. makeCookie(“OrderCookie”,34);
a. Cookie(“OrderCookie”,34);
a. OrderCookie(34);
25. What would occur if a fatal error was thrown in your PHP program?
Answers:
a. The PHP program will stop executing at the point where the error occurred.
b. The PHP program will show a warning message and program will continue executing.
c. Since PHP is a scripting language so it does not have fatal error.
d. Nothing will happen.
26. What is the correct line to use within the php.ini file, to specify that 128MB would be the maximum amount of memory that a script may use?
Answers:
a. memory_limit = 128M
b. limit_memory = 128M
c. memory_limit: 128M
d. limit_memory: 128M
27. What is the best way to change the key without changing the value of a PHP array element?
Answers:
a. $arr[$newkey] = $oldkey; unset($arr[$oldkey]);
b. $arr[$newkey] = $arr[$oldkey]; unset($arr[$oldkey]);
c. $newkey = $arr[$oldkey]; unset($arr[$oldkey]);
d. $arr[$newkey] = $oldkey.GetValue(); unset($arr[$oldkey]);
28. What will be the output of the following code?
<? echo 5 * 6 / 2 + 2 * 3; ?>
Answers:
a. 1
b. 20
a. 21
a. 23
b. 34
29. Does PHP 5 support exceptions?
Answers:
a. Yes
b. No
21 NOT Answered Yet Test Questions:
(hold on, will be updated soon)
30. Which of the the following are PHP file upload-related functions?
Answers:
a. upload_file()
b. is_uploaded_file()
c. move_uploaded_file()
d. None of these
31. Which of the following cryptographic functions in PHP returns the longest hash value?
Answers:
a. md5()
b. sha1()
c. crc32()
d. All return the same hash value length.
32. Which of the following is not a valid API?
Answers:
a. trigger_print_error()
b. trigger_error()
c. debug_backtrace()
d. debug_print_backtrace()
33.
What will be the output of the following code?

Answers:
a. 150 . 7
b. 1507
c. 150.7
d. Integers can’t be concatenated.
a. An error will be thrown.
34. Which of these is not a valid SimpleXML Parser method?
Answers:
a. simplexml_import_dom()
b. simplexml_import_sax()
c. simplexml_load_file()
d. simplexml_load_string()
35. Which of the following environment variables is used to fetch the IP address of the user in a PHP application?
Answers:
a. $IP_ADDR
b. $REMOTE_ADDR_USER
c. $REMOTE_ADDR
d. $IP_ADDR_USER
36. Consider the following class:
1 class Insurance
2 {
3 function clsName()
4 {
5 echo get_class($this);
6 }
7 }
8 $cl = new Insurance();
9 $cl->clsName();
10 Insurance::clsName();
Which of the following lines should be commented to print the class name without errors?
Answers:
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.
37. What is the correct syntax of mail() function in PHP?
Answers:
a. mail($to,$subject,$message,$headers)
b. mail($from,$to,$subject,$message)
c. mail($to,$from,$subject,$message)
d. mail($to,$from,$message,$headers)
38. Given the following array:
$array = array(0 => ‘blue’, 1 => ‘red’, 2 => ‘green’, 3 => ‘red’);
Which one of the following will print 2?
Answers:
a. echo array_search(‘green’, $array);
b. echo in_array(‘green’, $array);
c. echo array_key_exists(2, $array);
d. echo array_search(‘red’,$array);
39. Which function will suitably replace ‘X’ if the size of a file needs to be checked?
$size=X(filename);
Answers:
a. filesize
b. size
c. sizeofFile
d. getSize
40. Which of the following will not give the correct date and time in PHP?
Answers:
a. date(“Y-m-d H:i:s”)
b. date(“y-m-d H:i:s”)
c. date(“f, j Y H:i:s”)
d. date(“F, j Y H:i:s”)
41. Which of the following functions is not used in debugging?
Answers:
a. var_dump()
b. fprintf()
c. print_r()
d. var_export()
42. What is the difference between die() and exit() in PHP?
Answers:
a. die() is an alias for exit().
b. exit() is a function, die() is a language construct and cannot be called using variable functions.
c. die() accepts a string as its optional parameter which is printed before the application terminates; exit() accepts an integer as its optional parameter which is passed to the operating system as the exit code.
d. die() terminates the script immediately, exit() calls shutdown functions and object destructors first.
43. Should assert() be used to check user input?
Answers:
a. Yes
b. No
44. Without introducing a non-class member variable, which of the following can be used to keep an eye on the existing number of objects of a given class?
Answers:
a. Adding a member variable that gets incremented in the default constructor and decremented in the destructor.
b. Adding 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.”
45. Which of the following is the right MIME to use as a Content Type for JSON data?
Answers:
a. text/x-json
b. text/javascript
c. application/json
d. application/x-javascript
46.
What would be the output of the following code?
$arr = array(“foo”,
“bar”,
“baz”);
for ($i = 0; $i < count($arr); $i++) {
$item = $arr[$i];
}
echo ”
";
print_r($item);
echo "
“;
?>
Answers:
a. Array ( [0] => foo [1] => bar [2] => baz )
b. foo
c. bar
d. baz
47. Which of the following is the correct way to check if a session has already been started?
Answers:
a. if ($_SERVER[“session_id”]) echo ‘session started’;
b. if (session_id()) echo ‘session started’;
c. if ($_SESSION[“session_id”]) echo ‘session started’;
d. if ($GLOBALS[“session_id”]) echo ‘session started’;
48. What is the correct PHP command to use to catch any error messages within the code?
Answers:
a. set_error(‘set_error’);
b. set_error_handler(‘error_handler’);
c. set_handler(‘set_handler’);
d. set_exception(‘set_exception’);
49.
What is wrong with the following code?

Answers:
a. There is nothing wrong with the code.
b. The cURL resource $ch has not been created using the curl_init() method.
c. The $ch variable needs to be initialized as $ch=null;.
d. The code will cause a parse error.
50. With what encoding does chr() work?
Answers:
a. ASCII
b. UTF-8
c. UTF-16
d. Implementation dependent
e. None of these

Freelancer Exams Questions & Answers: PHP Level 1 - PART II

PHP Level 1 Exam


1. What is the correct way to add 1 to the $counter variable?

Answer: $counter++;

2. What function raises the first argument to the power of the second argument, with decimal places to be specified by the scale factor?

Answer: bcpow();

Example:
 <?php echo bcpow('4.2''3'2); // 74.08 ?>

3. Which operator performs the same function as x=x%y?
Answer: %=

Example
<?php

$x = 9;
$y = 4;

echo $x%$y;  // output is: 1

echo $x %= $y; // output is: 1

?>

4. Which file mode will read and write to the end of an existing file or create a new file?
Answer: w+

Basic file modes
rRead only. Starts at the beginning of the file
r+Read/Write. Starts at the beginning of the file
wWrite only. Opens and clears the contents of file; or creates a new file if it doesn't exist
w+Read/Write. Opens and clears the contents of file; or creates a new file if it doesn't exist
aAppend. Opens and writes to the end of the file or creates a new file if it doesn't exist
a+Read/Append. Preserves file content by writing to the end of the file
xWrite only. Creates a new file. Returns FALSE and an error if file already exists
x+Read/Write. Creates a new file. Returns FALSE and an error if file already exists


5. Which of the following is correct for adding a comment in a PHP script?
Answer: /* comment */

Type of comments in PHP
 //   or  #   single line comment
/* */            multi line  comment


6. Which function returns (and caches) the owner ID number?
Answer: fileowner()

7. Which of the following is the correct way to implement a do-while loop?
Answer:  
$j = 0; 
do { print "$j"; } 
while ($j > 0);

8. Which statement will skip the rest of the current loop iteration and continue execution at the beginning of next iteration.

Answer: continue

9. Which of the following is correct to show a message for an exception?
Answer: throw new Exception ("Invalid data");

Example
<?php

function inverse($x) {
    if (!$x) {
        throw new Exception('Division by zero.');
    }
    return 1/$x;
}
?>


10. What term refers to the ability to shorten Extra_Long_Names improving readability of source code? 
Answer: Aliasing 

11. What PHP function returns the arctangent in radians of a numerical argument?
Answer: atan()

12.Which function is used to start tracking a user?
Answer: session_start()

13. What statement will delete session files?
Answer: session_destroy()

14. How are sessions tracked on PHP
Answer: with code rewriting using the PHP Session reference variable

15. The file handle argument in fread() allows you to specify ___________.
Answer: the number of bytes you wish to read


PHP Level 1 Exam

1. What is the correct way to add 1 to the $counter variable?
Answer: $counter++;

2. What function raises the first argument to the power of the second argument, with decimal places to be specified by the scale factor?
Answer: bcpow();

 

3. Which operator performs the same function as x=x%y?
Answer: %=

4. Which file mode will read and write to the end of an existing file or create a new file?
Answer: w+

Basic file modes 
r
Read only. Starts at the beginning of the file
r+
Read/Write. Starts at the beginning of the file
w
Write only. Opens and clears the contents of file; or creates a new file if it doesn't exist
w+
Read/Write. Opens and clears the contents of file; or creates a new file if it doesn't exist
a
Append. Opens and writes to the end of the file or creates a new file if it doesn't exist
a+
Read/Append. Preserves file content by writing to the end of the file
x
Write only. Creates a new file. Returns FALSE and an error if file already exists
x+
Read/Write. Creates a new file. Returns FALSE and an error if file already exists


5. Which of the following is correct for adding a comment in a PHP script?
Answer: /* comment */

Type of comments in PHP
 //   or  #   single line comment
/* */            multi line  comment


6. Which function returns (and caches) the owner ID number?
Answer: fileowner()

7. Which of the following is the correct way to implement a do-while loop?
Answer:
$j = 0;
do { print "$j"; }
while ($j > 0);
 


8. Which statement will skip the rest of the current loop iteration and continue execution at the beginning of next iteration.
Answer: continue

9. Which of the following is correct to show a message for an exception?
Answer: throw new Exception ("Invalid data"); 


10. What term refers to the ability to shorten Extra_Long_Names improving readability of source code? 
Answer: Aliasing 

11. What PHP function returns the arctangent in radians of a numerical argument?
Answer: atan()

12.Which function is used to start tracking a user?
Answer: session_start()

13. What statement will delete session files?
Answer: session_destroy()

14. How are sessions tracked on PHP
Answer: with code rewriting using the PHP Session reference variable 


15. The file handle argument in fread() allows you to specify ___________.
Answer: the number of bytes you wish to read

Freelancer tests and answers : PHP - Level 1

1) Which function returns (and caches) the owner ID number?
Answer: fileowner()

2) Which of the following is the correct way to implement a do-while loop?
Answer: $j=0; do { print "$j"; } while ($j > 0);

3)Which statement will skip the rest of the current loop iteration and continue execution at the beginning of next iteration.
Answer: continue

4) Which of the following is correct to show a message for an exception?
Answer: throw new Exception ("Invalid data");

5) What term refers to the ability to shorten Extra_Long_Names improving readability of source code?
Answer: Aliasing

6) Which operator performs the same function as x=x%y?
Answer: %=

7)The control error operator is:
Answer: @

8)Which of the following is the not equal operator?
Answer: !=

9) What are the levels of visibility possible for a variable or method?
Answer: Public, Private and Protected

10) Which Perl Compatible Regex function takes a regex pattern as first argument, a string to match against as second argument, and an optional array variable for returned matches?
Answer: preg_grep

11) Which Perl Compatible Regex function inserts escape characters into strings that are intended for use as regex patterns.
Answer: preg_quote

12)Which of the following shifts the bits of $a $b steps to the left?
Answer: $a << $b

13) What PHP function returns the arctangent in radians of a numerical argument?
Answer: atan()

14) Which function is used to start tracking a user?
Answer: session_start();

15) What statement will delete session files?
Answer: session_destroy();

16) How are sessions tracked on PHP
Answer: With code rewriting using the PHP Session reference variable

17) Which function changes server parameters and status at runtime?
Answer: Memcache::setServerParams

18) Which function forces a write of all buffered output to the resource pointed to by the file handle?
Answer: fflush

19) Single-line comments in PHP use the following:
Answer: //

20) The ability of a class to protect access to its internal member variables is called:
Answer: encapsulation

21) You can use what function in order to check if a constant is set?
Answer: defined();

22) Which of these will perform integer rather than floating point division?
Answer: intval(x/y);

23) ______________ is a mechanism for storing data in the remote browser and thus tracking or identifying return users.
Answer: Cookies

24) Using the Zip Archive Class, which of the following will include a file to a ZIP archive from a given path?
Answer: zipArchive::addFile

25) Which of the following is an example of predefined cURL constant?
Answer: All of these

CURLAUTH_ANYSAFE
CURLFTPSSL_NONE
CURLOPT_FILE
CURLOPT_VERBOSE

26) Which of the following refers to a set of functions that allows you have access to multiple supported databases without writing your own wrapper functions?
Answer: PHP DBX

27) Which of the following is the correct syntax to retrieve an object from the memcache module?
Answer: $result = $memcache->get('key');

28) _____________ attempts to establish an FTP connection to a remote server by emulating an FTP client.
Answer: FTP ftp_connect()

29) Which of the following will open the file "time.txt" as readable?
Answer: fopen("time.txt","r");

30) Which character must be set in the $mode argument for fopen($file, $mode) to open a file for reading and writing?
Answer: r+;

31) Which of the following is the correct way to implement a "for" control structure?
Answer: for($i=0; $i<10; $i++){ // do something }

32) Which of the following is the only keyword that can be written before the namespace at the top of the file?
Answer: declare

33) What is the correct way to access the property of a PHP object?
Answer: $obj->property

34) Select the convention sign used to indicate private variables and functions:
Answer: _ for $_name

35) Arrays can be sorted with which of the following functions?
Answer: arsort(), ksort() and uksort();

36) Private members are accessible to:
Answer: The class itself and the classes that inherit from it

37) Which function returns the square root of its argument, with number of decimal places set by the optional scale factor?
Answer: bcsqrt()

38) What 2 types of parsers are used in PHP?
Answer: T_ABSTRACT & T_ARRAY_CAST

39) What does MIME stand for?
Answer: Multipurpose Internet Mail Extensions

40) Which configuration directive defines a comma separated list of server urls to use for session storage?
Answer: session.save_path

41) Which function gets permissions for the given file?
Answer: fileperms

42) Which function checks whether a file or directory exists?
Answer: file_exists

43) PHP constants:
Answer: All of these

Do not have a dollar sign ($) before them.
May be defined and accessed anywhere without regard to variable scoping rules
May not be redefined or undefined once they have been set.
May only evaluate to scalar values.

44) Which PHP operator type allows evaluation and manipulation of specific bits within an integer?
Answer: Bitwise operators

45) At compile time static values are bound with
Answer: a name

46) Which Perl Compatible Regex character will cause any special character to be treated as a simple matching character?
Answer: \

47) Session files should not be stored on a directory viewable from the Web server because:
Answer: Malicious users may access other users' login details

48) Which API reads in an XML file and creates a "walkable" object tree in memory, so it can be used in large documents?
Answer: DOM

49) What APIs are used for handling XML documents?
Answer: Document Object Model (DOM) and Simple API for XML (SAX)

50) ________________ tests for the end of file on a file pointer.
Answer: feof()

51) Include files must have the file extension:
Answer: none of these

52) What is the term for using a class to create an object?
Answer: Instantiation

53) PHP constants:
Answer: All of these apply

Can be accessed anywhere in the script regardless of the scope.
Can be used as default argument values.
Cannot change during the execution of the script.
Follow the same rules as labels in PHP.

54) Which statement can replace several else Statements?
Answer: switch

55) To retrieve information from a form that is submitted using the "get" method, use ___________.
Answer: $_GET[];

56) Which POSIX function takes the following two string arguments and an optional third-array argument: A POSIX-style regular expression pattern, and the target string to be matched?
Answer: ereg()

57) Which PHP operator will attempt to execute its contents as a shell command?
Answer: (` `)

58) What function takes any number of numerical arguments and returns the largest of the arguments?
Answer: max()

59) To unregister a session variable STRING use:
Answer: session_unregister(STRING);

60) Which of the following is correct to select a database in MS SQL?
Answer: mssql_select_db(STRING)

61) Select the variable used to set the php.ini file to send emails containing the address of the default PHP mail sender.
Answer: sendmail_from

62) Which configuration directive is used to transparently failover to other servers on errors?
Answer: memcache.allow_failover

63) Which PHP function is identical to the C fwrite() function?
Answer: fputs()

64) Which function writes a string to a file?
Answer: file_put_contents

65) To denote strings in PHP, you can use both double quotes " " and which other characters?
Answer: single quotes ' '

66) What kind of elements can be contained in constants?
Answer: All of these

Boolean
Float
String
integer

67) Which PHP operator type allows you to execute its contents as a shell command?
Answer: Execution operator

68) PHP variables start with the following symbol:
Answer: $

69) Which POSIX function takes a pattern, a target string, and an optional limit on the number of portions to split the string into.
Answer: split

70) What function raises the first argument to the power of the second argument, with decimal places to be specified by the scale factor?
Answer: bcpow

71) Instead of a single new line character some clients require which characters?
Answer: "\r\n"

72) Which function parses input from a file according to a format?
Answer: fscanf

73) Which file should be edited to set configuration directives?
Answer: php.ini

74) Which of the following is correct in PHP?
Answer: Zero is interpreted as false

75) Which parameter of setcookie() defines the amount of time for which a cookie is valid?
Answer: expire

76) Which control structure allows you to quickly traverse through an array?
Answer: foreach loops

77) Which types of code can be affected by namespaces?
Answer: Classes, functions and constants.

Although any valid PHP code can be contained within a namespace, only four types of code are affected by namespaces: classes, interfaces, functions and constants.

78) Which cURL function returns the last error number?
Answer: curl_errno

79) Which of the following is an invalid constant name?
Answer: 2DAY

80) Which PHP operator allows you to assign values to variables and arrays?
Answer: "="

81) What is the term for breaking the binding between a variable name and variable content?
Answer: Unsetting references.

82) Which is the operator for the integer remainder from the division of two values?
Answer: %

83) Which predefined Memcache function turns on data compression?
Answer: MEMCACHE_COMPRESSED

84) Which compressed file type can be decompressed without specifying the extension?
Answer: zip

85) Which configuration directive, in conjunction with memcache.allow_failover, defines how many servers to try when setting and getting data?
Answer: memcache.max_failover_attempts

86) The correct way to create a numeric variable "v" that might have any real number is:
Answer: $v;

87) Which of the following databases are supported by PHP?
Answer: All of these

MySQL abd MS SQL
Oracle and Informix
PostgreSQL and Frontbase
mSQL and Interbase

88) Which of the following is the line to enable in the php.ini file for Windows in order to be able to use DBX?
Answer: extension=php_dbx.dll

89) Which of the following is the correct way to connect to a mySQL Server?
Answer: mysql_connect(SERVER, USER, PASSWORD);

90) Which of the following will return variables from a form sent by the HTTP POST method in PHP?
Answer: $_POST

91) Which version of PHP introduced object oriented programming?
Answer: PHP III

92) Which of the following will correctly create a constant "const"?
Answer: const const;

93) What variable is used by session cookies as a user ID?
Answer: $PHPSESSID

94) Functions that represent a behavior of a class are called _________.
Answer: Methods

95) Which zip function retrieves the compressed size of a directory entry?
Answer: zip_entry_compressedsize

96) What does cURL stand for?
Answer: Client URL

97) Which function clears the cache of file status info?
Answer: clearstatcache

98) Which method defines HTTP Authentication using Apache Server?
Answer: .htaccess files

99) What is the most widely accepted meaning of the acronym "PHP" today?
Answer: PHP: Hypertext Preprocessor

100) _______________ defines a cookie to be sent along with the rest of the HTTP headers.
Answer: setcookie()

101) The file handle argument in fread() allows you to specify ___________.
Answer: the number of bytes you wish to read

102) $count = $count + 8; can be written as:
Answer: $count += 8;

103) Which of the following is a special PHP variable that is used under HTTP Authentication?
Answer: $_PHP_AUTH_USER

104) XML is used for:
Answer: All of these
Data manipulation and storage
Display formatted data in a browser using style sheets.
transfer data between organizations
transfer data between software applications

105) Which kind of reference action allows you to have two variables referring to the same content?
Answer: Assign by reference.

106) ____________ describes the structure of a class of XML documents, specifying how elements are related and allowed.
Answer: Document Type Definition

107) Which parameter of setcookie() indicates that the cookie should only be transmitted over a secure HTTPS connection from the client?
Answer: secure

108) Which of the following can be included in a phar file?
Answer: All of these
a manifest describing the contents
a signature for verifying integrity
a stub
the file contents

109) Which of the following will encrypt a password?
Answer: crypt($password);

110) Which of the following will connect to a data base using PEAR?
Answer: DB::connect(data_source_name);

111) Which of the following will return 1 if the Memcache session handler is available and 0 if not?
Answer: MEMCACHE_HAVE_SESSION

112) Which bz library function returns bzip2 encoded data after compressing a given string?
Answer: bzcompress()

113) Which function opens a memcached server persistent connection?
Answer: Memcache::pconnect

114) On the additional header that PHP allows you to include on an email you can add:
Answer: All of these

Content-transfer-encoding
Content-type
MIME version
X-mailer and version number

115) __________ is the same as setcookie() but the cookie value will not be automatically urlencoded when sent to the browser.
Answer: setrawcookie()

116) Which function enables automatic compression of large values?
Answer: Memcache::setCompressThreshold

117) Which of the following will send queries to a database using PEAR?
Answer: none of these

$dbconn=query(QUERY)
$dbconn=query->(QUERY)
DB::query(QUERY)
DB::query->(QUERY)

118) Which PHP library allows you to connect to and communicate with different types of servers using many different types of protocol?
Answer: cURL

119) Which configuration directive sets the size of data chunks for transfers?
Answer: memcache.chunk_size

120) What does PEAR stand for?
Answer: PHP Extension and Application Repository

121) Which of the following functions are used to encrypt passwords?
Answer: md5() and crypt()

122) Which cURL function sets an option on the given cURL session handle?
Answer: curl_setopt

123) Which of the following are examples of resource types in cURL?
Answer: cURL handle and a cURL multi handle

124) Which API treats XML as flow-through string data?
Answer: CAX

125) What does XML mean?
Answer: eXtensible Markup Language

126) singleton design pattern
Answer: Sometimes it's important to have only one instance for a class. For example, in a system there should be only one window manager (or only a file system or only a print spooler). Usually singletons are used for centralized management of internal or external resources and they provide a global point of access to themselves.

127) PHP magic constant
Answer: __LINE__

128) When a small window pops up in front of the browser asking your username and a password, what kind of Authentication is being used?
Answer: HTTP

129) In session management cookies are usually not used for:
Answer: logging the user in for the first time

130) Which function returns the version of the server?
Answer: Memcache::getVersion

131) Which character must be set in the $mode argument for fopen($file, $mode) to open a file for reading and writing?
Answer: r+;

132) Which of the following will open the file "time.txt" as readable?
Answer: fopen("time.txt","r");

133) _____________ attempts to establish an FTP connection to a remote server by emulating an FTP client.
Answer: FTP ftp_connect()

134) Which of the following is the correct syntax to retrieve an object from the memcache module?
Answer: $result = $memcache->get('key');

135) Which of these will perform integer rather than floating point division?
Answer: intval(x/y)

136) $count = $count * 3; can be written as:
Answer: $count *= 3;

137) What is the correct way to add 1 to the $counter variable?
Answer: $counter++;

138) Which operator appends the argument on the right side to the argument on the left side?
Answer: .=

139) With the ________ bitwise operator, the bits set in $a are not set, and the not set bits are then set.
Answer: ~

140) Which bitwise operator will set the bits that are set in either $a or $b.
Answer: " | "

141) Which of the following allows you to set a user-defined exception handler function?
Answer: set_exception_handler

142) In an object method, which of the following is always a reference to the caller object?
Answer: $this

143) Which kind of reference is used by creating a local variable in a function and a variable in the calling scope referencing the same content?
Answer: Assign by reference.

144) Which of the following returns the remainder of $a divided by $b?
Answer: $a % $b

145) What PHP operator is used to access methods and properties of objects?
Answer: " -> "

146) Which interface type allows you to chain methods of an object together?
Answer: Fluent Interfaces

147) Interfaces define a "contract" specifying that an object is capable of implementing a method ____________.
Answer: Specifying exactly how is to be done.

148) What is the correct way to create a function in PHP?
Answer: function yourFunction()

149) Which of the following will print "Hi " followed a name argument passed to the function?
Answer: function sayHi ($name){ print "Hi $name"; }

150) A special method to perform any activity required to instantiate an object is called a(n) __________.
Answer: Constructor

151) Which POSIX character matches zero or more instances of the previous regular expression?
Answer: *

152) Which POSIX character matches any character?
Answer: .

153) If an exception is not caught, a PHP Fatal Error will be issued with what message?
Answer: "Uncaught Exception ..."

154) Which statement retrieves the value of a function after it is called?
Answer: return

155) Which "magic" constant implemented inside an include, returns the directory of the included file.
Answer: _DIR_

156) Which function returns a string containing a byte-stream representation of any value that can be stored in PHP?
Answer: serialize()

157) How do you write "Hello World 2010" in PHP?
Answer: echo "Hello World 2010";

158) Which command returns the filename component of a path?
Answer: string basename ( string $path [, string $suffix ] )

159) Which file mode will read and write to the end of an existing file or create a new file?
Answer: "a+"

160) Which server verifies the name password and mail spool location?
Answer: SMTP Server

161) What does MTA stand for?
Answer: Mail Transfer Agent

162) The agent used to collect and access the mail spool is called:
Answer: Mail Transfer Agent - not sure

163) __________ is an extension that provides a way to put entire PHP applications into a single file called PHP Archive for easy distribution and installation.
Answer: phar

164) Which function is used to connect to a database using Authentication by SQL Database Query?
Answer: @mysql_connect("localhost","databaseuser","password")

165) Which function takes a single argument and returns the largest integer that is less or equal to that argument?
Answer: floor()

166) Which function takes a single argument and returns the smallest integer that is greater than or equal to that argument?
Answer: ceil()

167) What is the expression for returning the square root of 2?
Answer: sqrt(2)

168) Which Perl Compatible Regex function takes a regex pattern and an array and returns an array of the elements of the input array that matched the pattern?
Answer: preg_grep

169) Protected members are available to:
Answer: The class itself and the classes that inherit from it

170) Which of these variables has an illegal name?
Answer: $your-Var

171) A(n) _____________ is an ordered map that assigns values to keys:
Answer: array

172) What PHP type represents a series of characters?
Answer: string

173) Which of the following is NOT a correct way to specify a string?
Answer: alfanum syntax

Strings in PHP can be specified in four different ways: single quoted, double quoted, heredoc syntax and (since PHP 5.3.0) nowdoc syntax

174) Which of the following allows you to express any real number?
Answer: double

175) Which of the following is the correct way to create a reference to a global variable?
Answer: $var =& $GLOBALS["var"];

176) Which of the following provides a means to access the same content on PHP variables by different names?
Answer: References

177) Which PHP operator is used to concatenate strings?
Answer: "."

178) What PHP token that allows access to static, constant, and overridden properties or methods of a class?
Answer: ::

179) Which PHP operator type returns the result of string arguments?)
Answer: String operators

180) Which of these restrictions applies to namespace implementation?
Answer: Nested namespaces are prohibited.

181) What term applies to an identifier with a namespace separator that begins with a namespace separator, such as \Foo\Bar?
Answer: Fully qualified name.

182) Which of the following objects lets you create code which specifies which methods a class must implement, without specifying how the objects are handled?
Answer: Interfaces

183) Which Interface allows you to use a design pattern that is characteristically changed with the instantiation of objects?
Answer: Instantation Design Interface

184) Which POSIX character matches the beginning of a string only?
Answer: ^

185) Which of the following are two broad classes of regular expressions that PHP works with?
Answer: POSIX and PHP-compatible regex

186) Which statement allows you to end a loop?
Answer: break

187) This "magic" constant refers to the name of the current namespace and it is defined in compile-time
Answer: _NAMESPACE_

188) What is the name for instances of a class that contain all the internal data and state information need for the application to run
Answer: Objects

189) ___________ allows a class to be defined as being a member of more than one category of classes
Answer: Polymorphism

190) The ability to define a class of one kind as being a subtype of a different kind of class is called:
Answer: Inheritance

191) Instantiate an object Demo: require_once('class.Demo.php');
Answer: $objDemo = new Demo();

192) Which of the following is correct for adding a comment in a PHP script?
Answer: /* comment */

193) Which function returns (and caches) file permissions level?
Answer: fileperms(file)

194) Which PHP function sets file modification time or creates a file if it does not exist?
Answer: touch(file, [time])

195) Which of these PHP file open modes are valid for the specified conditions?
Answer: All of these

196) The ____________ function can be used in combination with the PHP header() construct to assemble and send file downloads.
Answer: fpassthru

197) Which function returns (and caches) the time a file was last accessed?
Answer: fileatime(file)

198) How do you modify the php.ini file to have sessions work correctly on windows?
Answer: change session.save_path = /tmp to session.save_path=C:/temp

199) Which function gets statistics from all servers in a pool?
Answer: Memcache::getExtendedStats

200) Which of the following functions returns a Boolean value after attempting to send a message?
Answer: mail()

201) Which of the following is the correct way to connect to a MySQL database?
Answer: mysql_connect("localhost");

202) Which files should be used to install cURL in an include directory?
Answer: easy.h and curl.h files

203) Which function returns the largest number that may be returned by rand()?
Answer: getrandmax()

Monday, April 24, 2017

Top 25+ JIRA Interview Questions & Answers

Top JIRA Interview Questions & Answers

1) Explain what is JIRA?
JIRA is an issue tracking product or a software tool developed by Atlassian, commonly used for bug tracking, project management and issue tracking; it is entirely based on this three aspects.
2) Explain what is a workflow?
Workflow is defined as a movement of the bug/issue through various stages during its life-cycle
  • Created/Open
  • WIP ( Work In Progress)
  • Completed/Closed
3) What can be referred as an issue in JIRA?
In JIRA, an issue can be anything like a
  • Software bug
  • The project task
  • A help-desk ticket
  • The leave request form
4) List out the source control programs with which it integrates?
It integrates with source control programs such as CVS, Git, Subversion, Clearcase, Visual SourceSafe, Mercurial, and Perforce.
5) Why use JIRA?
The reason behind using JIRA is
  • Upfront and fair licensing policy
  • Features that is not available elsewhere
  • Get latest update on the progress of projects
  • It run anywhere and recognized with many famous companies
  • Easily extensible and customizable
images (1)
6) Is it possible to access JIRA cloud site via a mobile device?
Yes, it is possible to access JIRA cloud site via a mobile device. You have to just use the URL of the JIRA cloud site in your mobile web browser.
7) Can you disable JIRA mobile for the site?
You can disable JIRA mobile for the site, so that users can be unable to operate the desktop view of JIRA on their mobile device.  JIRA mobile comes as a system add-on and can be disabled any time.

8) Explain labelling and linking issue in JIRA?
  • Labelling Issue: It enables you to categorize an issue in a more informal way than assigning it to a component or version. You can then search issues according to label.
  • Linking Issue: This feature enables you to link an association between two issues on either on the same or different JIRA servers.
9) Mention the types of reports generated in JIRA?
JIRA offer reports that show statistics for projects, versions, people or other fields within issues.  Various reports included with JIRA are
  • Average Age Report
  • Pie Chart Report
  • Resolution Time Report
  • Recently Created Issues Report
  • Resolved vs. Created Issues Report
  • Single Level Group by Report
  • Time Tracking Report
  • User Workload Report
  • Workload Pie Chart Report, etc.
10) Explain what is Cloning an Issue?
Cloning as issue allows you to create a duplicate of the original issue so that many employees can work on a single issue within a single project. The clone issue can be connected to the original issue.  A clone issue holds following the information
  • Summary
  • Description
  • Assignee
  • Environment
  • Priority
  • Issue Type
  • Security
  • Reporter
  • Components, etc.
11) Mention what things are not included in cloned issue in JIRA?
  • Time tracking
  • Issue history
  • Comments
12) Explain what is the use of “Move Issue” wizard in JIRA?
The move issue wizard enables you to specify another project in your JIRA instance. Move wizard permit you to change certain attributes of an issue like
  • Issue Type: If your issue is a custom issue type and does not occur in your target project, you must choose a new issue type for your issue
  • Issue Status: If you have assigned your issue as a custom issue status and it does not exist in your project, you must select a new issue status for your issue
  • Custom Fields: If you have determined required custom fields for your issue, which do not occur in the target project, you must set values for them.
13) How security setting is helpful in JIRA?
JIRA’S security setting restricts the access to the issue to only those person who is allowed to work on the issue or a member of the chosen security level. Security level of an issue can be set either when the issue is created or when the issue is being edited
14) Explain how you can share an issue with other users?
You can email an issue by using the share option in JIRA. You can also email other JIRA users a link to the issue by sharing the issue with them or by mentioning them in an issue’s Description or Comment field.
15) Explain how you can modify multiple bulk issues?
To modify multiple bulk issues, you can use Bulk Change option from the “Tools” menu of the navigator.  All the issues on the current page can be selected for the bulk operation.  The following list details the available bulk operations like
  • Workflow Transition
  • Delete
  • Move
  • Edit
16) Explain how you can disable mail notification for Bulk Operations?
To disable mail notification for a particular Bulk Operations, you have to de-select the “Send Notification” checkbox in the bulk operation wizard.
17) What does an issue change history include?
Issue change history includes
  • Deletion of a comment
  • Deletion of a worklog
  • Creation or deletion of an issue link
  • Attachment of a file
  • Changes to an issue field
18) Explain what does the three color indicates tracking times or duration for an issue?
Three color will be displayed representing the amount of time spent behind the issue
  • Original Estimate (Blue): The amount of time originally estimated to resolve the issue
  • Remaining Estimate(Orange): The remaining amount of time left to resolve the issue
  • Time Spen or Logged (Green): The amount of time spent so far while resolving the issue
19) Mention some of the popular add-ons for JIRA?
Some popular add-ons for JIRA include,
  • Suites utilities for JIRA
  • ScriptRunner for JIRA
  • Zephyr for JIRA – Test Management
  • JIRA Toolkit Plugin
  • Atlassian REST API Browser
  • Portfolio for JIRA
  • JIRA Misc Workflow Extensions
  • Tempo Timesheets for JIRA
  • JIRA Charting Plugin
20) Mention what is Schemes in JIRA?
Schemes are a major part of JIRA configuration. It is a collection of configured values that can be used by one or more JIRA project. For instance, Notification Schemes, Permission Scheme, Issue Type Scheme, and so on. There are total seven types of schemes.
21) Mention what can be configured for JIRA project and issue type?
You can configure following things for each pair of an issue type and JIRA project.
  • The order of custom fields appears on an issue screen
  • Workflow of an issue including the statuses
  • Which custom fields and system an issue can use
  • Project accessibility
  • Permissions for what a user can do with an issue
  • Versions and components available for an issue
22) Mention is it possible to get back up your JIRA cloud data?
In JIRA, you can take backup of your JIRA cloud data using Backup Manager.  But only one backup file is stored at a time. The existing backup is overwritten by new ones.
23) Mention what data can be backed up?
The backup data includes,
  • Attachments if selected
  • Users and their group settings
  • Avatars
  • Issues
24) Mention some useful tips on JIRA Workflow?
  • As such Statuses are global objects in JIRA. Changing the name of the status on one workflow will change the status on all workflows that use that status
  • Hover over a status or transition to see the relevant transition labels
  • One cannot clone transitions in the workflow designer
  • In the workflow designer, one cannot create annotations
  • Directly you cannot set the issue.editable property.
25) Mention what are the limitations when editing an active workflow?

  • If a workflow is active, you cannot edit the workflow name (only the description)
  • You cannot delete the workflow steps
  • A step associated status cannot be edited
  • You cannot add any new outgoing transition if a step has no outgoing transitions (Global transitions are not considered).
  • A step’s Step ID cannot be changed.
26) In JIRA workflow, is it possible to transition an issue back to its previous status?
Practically, it is not possible to transition an issue back to its previous status.  However, you can use “onhold” feature to transition an issue back to its previous status. Here are the steps,
  • In workflow, Create a global transition to the ‘On Hold’ status.
  • Now from ‘On Hold’ status create another transition to every other status you want to come back to
  • Since the transition names cannot be the same, just add a blank space at the end of it.
  • Now you don’t want the status transition from the ‘On Hold’ and ‘Done’ to ‘On Hold’ So you will hide the other status “On Hold” by adding the value field condition on the global transition.
27) Mention what is the role of Validators in JIRA?
The Validators in JIRA checks that any input made to the transition is valid before the transition is performed.  If a validator fails, the issue will not progress to the destination status of the transition.
28) Mention what types of Post functions are carried out after the transition is executed?
Types of Post functions carried out after transition is executed includes
  • Adding a comment to an issue
  • Generating change history for an issue
  • Updating an issue’s fields
  • Generating an event to trigger email notifications
29) What is an event in JIRA?
The events are classified in two a System event (JIRA defined events) and Custom event (User defined events). An event describes the status, the default template and the notification scheme and workflow transition post function associations for the event.
30) What is Audit Log?
Under Audit Log, you can see all the details about the issue created, and the changes made in the issues.
31) For a Agile project, how user stories in JIRA are created?
For Agile project to create user stories in JIRA, follow below steps.
  • Issue type -Epic and Issue type – Story linked to it. In order to do so, in the ‘Create Issue’ page, go to “Configure Fields” and select “Epic link” field to be included in the issue creation screen.
  • Or you can have a product backlog by creating a main User story and having various sub-tasks under it.
32) Mention what is an “issue collector”?
An “issue collector” enables you to easily embed a JIRA feedback form into your own web site. This helps website visitors to log issues into JIRA through our website.  To use JIRA feedback form, visitors to our website do not need a user account in JIRA.
33) Mention the difference between Bugzilla and JIRA?
BugzillaJIRA
  • It is an Open Source
  • It is a commercial tool
  • Using Bugzilla might be little complicated for few due to grouping users and granting permissions
  • For some using JIRA would be more convenient than Bugzilla
  • Bugzilla allows you to show/hide the whole custom field or specific values based on the value of some other field
  • JIRA enables conditional configuration based only on Type fields and Project.
  • Bugzilla’s has a powerful advanced search option
  • JIRA lacks advance-level search options. JIRA has flexible JQL language (JIRA Query Language). It enables you to build arbitrary boolean expressions.
  • Unlike JIRA, Bugzilla allows users select the initial status of a new issue.
  • Unlike Bugzilla, JIRA enables you to define multiple workflows which are applied based on the issue’s Project and Type.
  • Bugzilla has only one link type: Blocks/depends and a Bug ID custom field
  • JIRA has configurable link types with user-defined semantics. JIRA enables to link an issue to any other entity outside JIRA.
34) Explain how you can modify multiple bulk issues?
You can modify multiple bulk issues by using option “Bulk Change” option.

lEARNING: SQL | WHERE Clause

SQL | WHERE Clause WHERE keyword is used for fetching filtered data in a result set. It is used to fetch data accord...