Database | Unit 7 | Adv PHP | Multiple Choice Questions With Answer

 











1.Where is the greatest use of MySQL server?

(a)   Full text indexing and searching 

(b)   Query caching         

(c)   Replication           

(d)    Security    

 

 

 

 

 

 

 

 

 

2.Which the correct coding for executing variables of mysql?

(a)   mysql.show variable “table_type”

(b)   mysql.show variables like “table_type”

(c)    mysql.show stats         

(d)    None

 

 

 

 

 

 

 

 

3.To use the mysqli extension which line is need to add?

(a)   extension = php_mysql.dll

(b)   extension = php_mysqli.dll

(c)    with.mysql[= DIR] 

(d)    php.info()

 

 

 

 

 

 

 

 

4.Which is the comment symbol in mysql?

(a)   &&        

(b)   /*….*/          

(c)    #        

(d)    %

 

 

 

 

 

 

 

 

5.max_allowed_packet, a packet is equivalent to both multiple SQL statement and multiple row return to the requesting client.

(a)   True                

(b)   False

 

 

 

 

 

 

 

 

6.By default MySQL communicates on-

(a)   port 16          

(b)   pot TCO/IP

(c)   port 4.01        

(d)   port 3306

 

 

 

 

 

 

 

 

 

 

7.The mysql function in php are—–?

(a)   Case sensitive              

(b)   Case insensitive

(c)    variable                         

(d)   constant

 

 

 

 

 

 

8.The mysql clients is an extremely useful?

(a)   sql shell                         

(b)   mysql shell

(c)   programming shell      

(d)   object shell

 

 

 

 

 

 

 

 

9. How to view all tables in mysql?

(a)   view tables                    

(b)   show tables

(c)   select tables                

(d)   atlar tables

 

 

 

 

 

 

 

 

 

10.                How to show structure of one tabels

(a)   Describe database name tables name

(b)   Alter database name tables name

(c)   Show database name tables name

(d)   None of the above

 

 

 

 

 

 

 

 

11.                How to show variables?

(a)   show variables             

(b)   view variables?

(c)   save variables?            

(d)   all of the above

 

 

 

 

 

 

 

 

12.                Why we can use LIKE commands?

(a)   To connect data            

(b)   To conjunction data

(c)   To looking data            

(d)   Matching data

 

 

 

 

 

 

 

 

13.                How to view a new database?

(a)   view database               

(b)   Show database

(c)   Describe database      

(d)   Create database

 

 

 

 

 

 

 

14.                How to create a new database?

(a) create database Name      

(b) describe database name

(c) creative database name    

(d) None of the above

 

 

 

 

 

 

 

 

 

15.                How to delete database?

(a)  create database            

(b)  drop database

(c)  delete database           

(d)  alter database

 

 

 

 

 

 

 

16.                How many types in database type categories?

(a)   Three         

(b) four           

(c) five          

(d) six

 

 

 

 

 

 

 

 

17.

Which are database type categories?

(a)   Date & time

(b)   numeric

(c)    string            

(d)    integer          Ans (a,b,c)

 

 

 

 

 

 

 

 

 

18.                Which format display mysql data values?

(a)   yyyy-dd-mm                

(b)   dd-mm-yyyy

(c)   mm-dd-yyyy                 

(d)   yyyy-mm-dd

 

 

 

 

 

 

19.                Which format display MySQL date time values?

(a)   yyy-dd-mm hh:mm:ss    

(b)  mm-dd-yyyy hh:mm:ss

(c)    dd-yyyy-mm hh:mm:ss  

(d)  yyyy-mm-dd hh:mm:ss

 

 

 

 

 

 

 

 

20.                Which is the largest integer range?

(a)   BIGINT     

(b)  INT       

(c)  MEDUWMINT   

(d)  SMALLINT

 

 

 

 

 

 

 

 

21.                Which is the second largest integer range/

(a)   BIGINT      

(b)   MEDUMINT      

(c)    INT     

(d)  SMALLINT

 

 

 

 

 

 

 

 

22.                Which is the third largest integer range?

(a)   BIGINT     

(b)   INT         

(c)    MEDUMINT     

(d)  SMALLINT

 

 

 

 

 

 

 

 

23.                Which is the forth-largest integer rang?

(a)   BIGINT      

(b)   INT        

(c)    MEDUMINT      

(d)  SMALLINT

 

 

 

 

 

 

 

 

24.                Which is the small integer range?

(a)   INT      

(b)   TINYINT    

(c)   SMALLINT   

(d) None of them

 

 

 

 

 

 

 

 

25.                Which is the double precision floating point number?

(a)   semi-double     

(b)   float     

(c)    single       

(d)    double

 

 

 

 

 

 

 

26.                The CHAR data type offer——–string representation?

(a)   fixed-length                                

(b)   variable-length

(c)   attribute-length                           

(d)   char-length

 

 

 

 

 

 

 

 

27.                What is the maximum value support in CHAR data type?

(a)   256            

(b)   255            

(c)    254         

(d)   65255

 

 

 

 

 

 

 

 

28.                The VARCHAR data type offer——– string representation

(a)   varchar-length                             

(b)   fixed-length

(c)   variable-length                            

(d)   attribute-length

 

 

 

 

 

 

 

 

29.                What is the maximum value support in VARCHAR data type?

(a)   254           

(b)   255             

(c)    256         

(d)    65535

 

 

 

 

 

 

 

30.                What is the largest binary string representation?

(a)   LONGBLOB                                   

(b)   LONGTEXT

(c)   MEDIUMBLOB                              

(d)   MEDIUMTEXT

 

 

 

 

 

 

 

31.                What is the largest non-binary string representation?

(a)   LONGBLOB                                    

(b)   LONGTEXT    

(c)    MEDIUMBLOB                           

(d)   MEDIUMTEXT

 

 

 

 

 

 

 

32.                What is the second largest binary string representation?

(a)   LONGBLOB                                   

(b)   LONGTEXT

(c)   MEDIUMBLOB                              

(d)   MEDIUMTEXT

 

 

 

 

 

 

 

33.                What is the second-largest non-binary string representation?

(a)   LONGTEXT                                     

(b)   LONTBLOB

(c)    MEDIUMBLOB                              

(d)    MEDIUMTEXT

 

 

 

 

 

 

 

 

 

34.                What is the third-largest binary representation?

(a)   TEXT      

(b)   BLOB        

(c)    LONG      

(d) MEDIUM

 

 

 

 

 

 

1. Which directive determines whether PHP scripts on the server can accept file uploads?
a) file_uploads
b) file_upload
c) file_input
d) file_intake
 

Answer: a
Explanation:By default its value is on.

 

 

 

 

 

 

 

 

 

2. Which of the following directive determines the maximum amount of time that a PHP script will spend attempting to parse input before registering a fatal error?
a) max_take_time
b) max_intake_time
c) max_input_time
d) max_parse_time
 

Answer: c
Explanation:This is relevant because particularly large files can take some time to upload, eclipsing the time set by this directive.

 

 

 

3. What is the default value of max_input_time directive?
a) 30 seconds
b) 60 seconds
c) 120 seconds
d) 1 second
 

Answer: b
Explanation:None.

 

 

 

 

 

 

 

4. Since which version of PHP was the directive max_file_limit available.
a) PHP 5.2.1
b) PHP 5.2.2
c) PHP 5.2.12
d) PHP 5.2.21
 

Answer: c
Explanation:The max_file_limit directive sets an upper limit on the number of files which can be simultaneously uploaded.

 

 

 

 

 

 

5. What is the default value of the directive max_file_limit?
a) 10 files
b) 15 files
c) 20 files
d) 25 files
 

Answer: c
Explanation:None.

 

 

 

 

 

 

6. Which directive sets a maximum allowable amount of memory in megabytes that a script can allow?
a) max_size
b) post_max_size
c) max_memory_limit
d) memory_limit
 

Answer: d
Explanation:Its default value is 16M.

 

 

 

 

 

 

 

7. If you want to temporarily store uploaded files in the /tmp/phpuploads/ directory, which one of the following statement will you use?
a) upload_tmp_dir “/tmp/phpuploads/ directory”
b) upload_dir “/tmp/phpuploads/ directory”
c) upload_temp_dir “/tmp/phpuploads/ directory”
d) upload_temp_director “/tmp/phpuploads/ directory”
 

Answer: a
Explanation:None.

 

 

 

 

8. Which superglobal stores a variety of information pertinent to a file uploaded to the server via a PHP script?
a) $_FILE Array
b) $_FILEs Array
c) $_FILES_UPLOADED Array
d) $_FILE_UPLOADED Array
 

Answer: b
Explanation:None.

 

 

 

 

 

 

9. How many items are available in the $_FILES array?
a) 2
b) 3
c) 4
d) 5
 

Answer: d
Explanation: $_FILEs[‘userfile’][‘error’], $_FILEs[‘userfile’][‘name’], $_FILEs[‘userfile’][‘size’], $_FILEs[‘userfile’][‘tmp_name’], $_FILEs[‘userfile’][‘type’] are the five items in the array.

 

 

 

 

10. Which function is used to determine whether a file was uploaded?
a) is_file_uploaded()
b) is_uploaded_file()
c) file_uploaded(“filename”)
d) uploaded_file(“filename”)
 

Answer: b
Explanation:None.

 

 

 

 

 

 

1. What is the full form of DNS?
a) Digital Network System
b) Domain Network System
c) Digital Name Systmem
d) Domain Name System
 

Answer: d
Explanation:The Domain Name System(DNS) is what allows you to use domain names(e.g., example.com) in place of the corresponding IP address, such as 192.0.10.10.

 

 

 

 

 

2. Which one of the following function checks for the existence of DNS records?
a) checkdns()
b) checkdnsr()
c) checkdnsrr()
d) checkdnsa()
 

Answer: c
Explanation:DNS records are checked based on the supplied host value and optional DNS resource record type, returning TRUE if any records are located and FALSE otherwise.

 

 

 

 

 

3. Which one of the following function is used to return an array consisting of various DNS resource records pertinent to a specific domain?
a) dns_get_record()
b) dns_record()
c) dnsrr_get_record()
d) dnsrr_record()
 

Answer: a
Explanation:None.

 

 

 

 

 

 

4. Which one of the following function is used to retrieve the MX records for the domain specified by hostname?
a) getmx()
b) retrieve_mx()
c) getmxrr()
d) retrieve_mxrr()
 

Answer: c
Explanation:None.

 

 

 

 

 

 

5. What is the default port number of HTTP’s?
a) 70
b) 80
c) 90
d) 100
 

Answer: b
Explanation:None.

 

 

 

 

 

 

 

6. Which one of the following function returns the port number of a specified service?
a) getportname()
b) getservername()
c) getserverbyname()
d) getservbyname()
 

Answer: d
Explanation:Example- getservbyname(“http”,”tcp”) will return 80.

 

 

 

 

 

 

 

7. Which one of the following statements can be used to establish port 80 connection with www.nachi.com?
a) fsockopen(“www.nachi.com”, 80);
b) sockopen(80,”www.nachi.com”);
c) fsockopen(80,”www.nachi.com”);
d) sockopen(“www.nachi.com”, 80);
 

Answer: a
Explanation:The fsockopen() function establishes a connection to the resource designated by target on port.

 

 

 

 

 

8. Which one of the following function is used to send a e-mail using PHP script?
a) mail_send()
b) send_mail()
c) mailrr()
d) mail()
 

Answer: d
Explanation: mail(string to, string subject, string message,) using this you can send any mail.

 

 

 

 

 

9. How many configuration directives pertinent to PHP’s mail function are available?
a) 4
b) 5
c) 6
d) 7
 

Answer: b
Explanation:They are- SMTP, sendmail_from, sendmail_path, smtp_port, mail.force_extra_parameters.

 

 

 

 

 

10. Which of the following statements is used to add an attachment to the mail?
a) $mimemail->attachment(‘attachment.pdf’);
b) $mimemail=>attachment(‘attachment.pdf’);
c) $mimemail->addAttachment(‘attachment.pdf’);
d) $mimemail=>addAttachment(‘attachment.pdf’);
 

Answer: c
Explanation:Call the Mail_Mime object’s addAttachment() method passing in the attachment name and extension.

 

 

 

 

 

1. Which function is used to erase all session variables stored in the current session?
a) session_destroy()
b) session_change()
c) session_remove()
d) session_unset()
 

Answer: d
Explanation: This will not completely remove the session from the storage mechanism. If you want to completely destroy the session, you need to use the function session_destroy().

 

 

 

 

 

2. What will the function session_id() return is no parameter is passed?
a) Current Session Identification Number
b) Previous Session Identification Number
c) Last Session Identification Number
d) Error
 

Answer: a
Explanation:None.

 

 

 

 

 

 

3. Which one of the following statements should you use to set the session username to Nachi?
a) $SESSION[‘username’] = “Nachi”;
b) $_SESSION[‘username’] = “Nachi”;
c) session_start(“nachi”);
d) $SESSION_START[“username”] = “Nachi”;
 

Answer: b
Explanation:You need to refer the session variable ‘username’ in the context of the $_SESSION superglobal.

 

 

 

 

 

 

4. What will be the output of the following PHP code? Say your previous session username was nachi.

1.    unset($_SESSION['username']);

2.    printf("Username now set to: %s", $_SESSION['username']);

a) Username now set to: nachi
b) Username now set to: System
c) Username now set to:
d) Error
 

Answer: c
Explanation:To delete the session variable ‘username’ we use the unset() function.

 

 

 

5. An attacker somehow obtains an unsuspecting user’s SID and then using it to impersonate the user inorder to gain potentially sensitive information. This attack is known as..
a) session-fixation
b) session-fixing
c) session-hijack
d) session-copy
 

Answer: a
Explanation:You can minimize this risk by regenerating the session ID on each request while maintaining the session-specified data. PHP offers a convenient function named session_regenerate_id() that will replace the existing ID with a new one.

 

 

 

 

6. Which parameter determines whether the old session file will also be deleted when the session ID is regenerated?
a) delete_old_file
b) delete_old_session
c) delete_old_session_file
d) delete_session_file
 

Answer: b
Explanation:By default, this behavior is disabled.

 

 

 

 

 

7. Which function effectively deletes all sessions that have expired?
a) session_delete()
b) session_destroy()
c) session_garbage_collect()
d) session_expired_delete()
 

Answer: c
Explanation:None.

 

 

 

 

 

 

8. Which function is used to transform PHP’s session-handler behavior into that defined by your custom handler?
a) session_set_save()
b) session_set_save_handler()
c) Session_handler()
d) session_save_handler()
 

Answer: b
Explanation:None.

 

 

 

 

 

 

 

9. The session_start() function must appear..

a) after the html tag
b) after the body tag
c) before the body tag
d) before the html tag
 

Answer: d
Explanation:Like this: <?php session_start(); ?> <html>

 

 

 

 

 

10. What is the return type of session_set_save_handler() function?
a) boolean
b) integer
c) float
d) character
 

Answer: a
Explanation:Returns TRUE on success or FALSE on failure.

 

 

 

 

 

 

1. Which one of the following databases has PHP supported almost since the beginning?
a) Oracle Database
b) SQL
c) SQL+
d) MySQL
 

Answer: d
Explanation:None.

 

 

 

 

 

 

 

2. The updated MySQL extension released with

PHP 5 is typically referred to as..
a) MySQL
b) mysql
c) mysqli
d) mysqly
 

Answer: c
Explanation:The updated MySQL extension with PHP 5 is known as MySQL and typically referred to as mysqli.

 

 

 

 

 

3. Which one of the following lines need to be uncommented or added in the php.ini file so as to enable mysqli extension?
a) extension=php_mysqli.dll
b) extension=mysql.dll
c) extension=php_mysqli.dl
d) extension=mysqli.dl
 

Answer: a
Explanation:Also make sure that extension_dir directive points to the appropriate directory.

 

 

 

 

 

 

4. In which version of PHP was MySQL Native Driver(also known as mysqlnd) introduced?
a) PHP 5.0
b) PHP 5.1
c) PHP 5.2
d) PHP 5.3
 

Answer: d
Explanation:PHP required that MySQL client library be installed on the server from which PHP was communicating with MySQL, whether the MySQL server also happened to reside locally or elsewhere. PHP 5.3 removes this problem by introducing MySQL Native Driver.

 

 

 

 

 

5. Which one of the following statements is used to create a table?
a) CREATE TABLE table_name (column_name column_type);
b) CREATE table_name (column_type column_name);
c) CREATE table_name (column_name column_type);
d) CREATE TABLE table_name (column_type column_name);
 

Answer: a
Explanation:None.

 

 

 

 

6. Which one of the following statements instantiates the mysqli class?
a) mysqli = new mysqli()
b) $mysqli = new mysqli()
c) $mysqli->new.mysqli()
d) mysqli->new.mysqli()
 

Answer: b
Explanation:If you choose to interact with MySQL server using the object-oriented interface, you need to first instantiate the mysqli class via its constructor.

 

 

 

 

 

 

7.Which one of the following statements can be used to select the database?
a) $mysqli=select_db(‘databasename’);
b) mysqli=select_db(‘databasename’);
c) mysqli->select_db(‘databasename’);
d) $mysqli->select_db(‘databasename’);
 

Answer: d
Explanation:None.

 

 

 

 

 

8. Which one of the following methods can be used to diagnose and display information about a MySQL connection error?
a) connect_errno()
b) connect_error()
c) mysqli_connect_errno()
d) mysqli_connect_error()
 

Answer: c
Explanation:The mysqli extension includes a few features that can be used to capture error messages or alternatively you can use exceptions.

 

 

 

 

 

9. Which method returns the error code generated from the execution of the last MySQL function?
a) errno()
b) errnumber()
c) errorno()
d) errornumber()
 

Answer: a
Explanation:Error numbers are often used in lieu of natural-language message to ease software internationalization efforts and allow for customization of error messages.

 

 

 

 

10. If there is no error, then what will the error() method return?
a) TRUE
b) FALSE
c) Empty String
d) 0
 

Answer: c
Explanation:None.

 

 

 

 

 

 

1. Which one of the following statements should be used to include a file?
a) #include ‘filename’;
b) include ‘filename’;
c) @include ‘filename’;
d) #include ;
 

Answer: b
Explanation:An example of this-

 

 

 

 

 

 

2. Which one of the following methods is responsible for sending the query to the database?
a) query()
b) send_query()
c) sendquery()
d) query_send()
 

Answer: a
Explanation:Its prototype looks like-
class mysqli{
mixed query(string query [, int resultmode])
}

 

 

 

 

 

3. Which one of the following methods recuperates any memory consumed by a result set?
a) destroy()
b) remover()
c) alloc()
d) free()
 

Answer: d
Explanation:Once this method is executed, the result set is no longer available.

 

 

 

 

 

4. Which of the methods are used to manage result sets using both associative and indexed arrays?
a) get_array() and get_row()
b) get_array() and get_column()
c) fetch_array() and fetch_row()
d) fetch_array() and fetch_column()
 

Answer: c
Explanation: Their prototype is as follows-
calss mysqli_result{
mixed fetch_array ([int resulttype])
}

calss mysqli_result{
mixed fetch_row()
}

 

 

 

5. Which one of the following method is used to retrieve the number of rows affected by an INSERT, UPDATE, or DELETE query?
a) num_rows()
b) affected_rows()
c) changed_rows()
d) new_rows()
 

Answer: b
Explanation:The method num_rows() is only useful for determining the number of rows retrieved by a SELECT query. But to retrieve the number of rows affected by INSERT, UPDATE, or DELETE query, use affected_rows().

 

 

 

 

6. Which version of MySQL introduced the prepared statements?
a) MySQL 4.0
b) MySQL 4.1
c) MySQL 4.2
d) MySQL 4.3
 

Answer: b
Explanation:When the query() method is looped repeatedly it comes at a cost of both overhead, because of the need to repeatedly parsing of the almost identical query for validity, and coding convenience, because of the need to repeatedly reconfigure the query using the new values for each iteration. To help resolve the issues incurred by repeatedly executed queries, MySQL introduced prepared statements.

 

 

 

7. Which of the following methods is used to execute the statement after the parameters have been bound?
a) bind_param()
b) bind_result()
c) bound_param()
d) bound_result()
 

Answer: a
Explanation:Once the statement has been prepared, it needs to be executed. Exactly when it’s executed depends upon whether you want to work with bound parameters or bound results. In the case of bound parameters, you’d execute the statement after the parameters have been bound with the bind_param() method.

 

 

 

 

8. Which one of the following methods is used to recuperating prepared statements resources?
a) end()
b) finish()
c) final()
d) close()
 

Answer: d
Explanation:Once you’ve finished using a prepared statement, the resources it requires can be recuperated with the close() method.

 

 

 

 

9. Which method retrieves each row from the prepared statement result and assigns the fields to the bound results?
a) get_row()
b) fetch_row()
c) fetch()
d) row()
 

Answer: c
Explanation:Its prototype follows:
class mysqli{
boolean fetch()
}

 

 

 

 

10. Which method rolls back the present transaction?
a) commit()
b) undo()
c) back()
d) rollback()
 

Answer: d
Explanation: Its prototype follows:
class mysqli{
boolean rollback()
}

 

 

 

 

 

1. Which version of PHP introduced the static keyword?
a) PHP 4
b) PHP 5
c) PHP 5.2
d) PHP 5.3
 

Answer: b
Explanation: The static keyword was introduced with PHP 5. It cannot be used in PHP 4 scripts.

 

 

 

 

 

 

2. Which keyword is used to access a static method or property from within the same class(rather than from child)?
a) static
b) strat
c) self
d) set
 

Answer: c
Explanation: Self is to classes what the $this pseudo-variable is to objects.

 

 

 

 

 

 

3. In which of the following circumstance should you use a static reference to a non static method?
a) Making a method call using parent.
b) Making a method call using child.
c) Making an object call using parent.
d) Making an object call using child.
 

Answer: a
Explanation: Making a method call using parent is the only circumstance in which you should use a static reference to a non-static method.

 

 

 

 

 

 

4. Which one of the following variable cannot be used inside a static method?
a) $this
b) $get
c) $set
d) $date
 

Answer: a
Explanation: By definition, static methods are not invoked in the context of an object. For this reason, static methods and properties are often referred to as class variables and properties.

 

 

 

 

 

5. What does PDO stand for?
a) PHP Data Orientation
b) PHP Database Object
c) PHP Database Orientation
d) PHP Data Object
 

Answer: d
Explanation: The PDO class provides a common interface to different database applications.

 

 

 

 

 

 

6. Which version of PHP allows you to define constant properties within a class?
a) PHP 4
b) PHP 4.1
c) PHP 4.3
d) PHP 5
 

Answer: d
Explanation:None.

 

 

 

 

 

 

7. Which keyword is used to declare a constant property?
a) const
b) con
c) constant
d) _constant
 

Answer: a
Explanation: A constant property is declared with the const keyword. Like global constants, class constants cannot be changed once they are set.

 

 

 

 

 

 

 

 

8. Which one of the following is a constant variable?
a) const $name
b) const $NAME
c) constant NAME
d) const NAME
 

Answer: d
Explanation:Constants are not prefixed with a dollar sign like regular properties. By convention, they are often named using only uppercase characters

 

 

 

9. What will happen if you try to set a value to a constant once it has been declared?
a) The value of the variable will change
b) The value of the variable will not change
c) Parse Error
d) Nothing
 

Answer: c
Explanation:You should use constants when your property needs to be available across all instances of a class, and when the property value needs to be fixed and unchanging.

 

 

 

 

10. How many of the following can be contained in constants?
i) boolean
ii) integer
iii) float
iv) string
a) 1
b) 2
c) 3
d) 4
 

Answer: d
Explanation:All scalar data i.e boolean, integer, float and string can be contained in constants.

 


Post a Comment

0 Comments