MySQL Questions and Answers – Putting PHP to Work

This set of MySQL Database Multiple Choice Questions & Answers (MCQs) focuses on ” Putting PHP to Work”.

1. In PHP, if $a represents an array with numeric indices, how is the first element accessed?
a) $a[1]
b) $a[0]
c) $a.1
d) $a.0
View Answer

Answer: b
Explanation: If $a represents an array with numeric indices, its elements are accessed as $x[0], $x[1], and so on. In general terms, each element at the position i is accessed and used as $a[i – 1].

2. Arrays cannot have associative indices in PHP.
a) True
b) False
View Answer

Answer: b
Explanation: The PHP arrays can even have both numeric and associative elements. For example, $x[1] and $x[“large”] can both be the elements of the same array. $x can be an object, whose elements are accessed by the arrow ‘->’ operated.

3. In PHP, which operator is used to access property of an object?
a) .
b) *
c) ->
d) @
View Answer

Answer: c
Explanation: If $a represents an object, the properties it has can be accessed as $a->property-name. For instance, $a->white, $a->black, $a->blue, $a->red can be the properties of $a and accessed in this way.
advertisement
advertisement

4. PHP scripts are located in the web server document tree.
a) True
b) False
View Answer

Answer: a
Explanation: The PHP scripts are different from DBI scripts since PHP scripts are located within the web server document tree while DBI scripts are located in a cgi-bin directory located outside of document tree.

5. DBI scripts are located in the directory ______________
a) cgi-inc
b) cgi-bin
c) cgi-usr
d) cgi-perl
View Answer

Answer: b
Explanation: DBI scripts are located in a cgi-bin directory located outside of document tree. The PHP scripts are different from DBI scripts since PHP scripts are located within the web server document tree.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. A stored program associated with a schedule is ______________
a) Trigger
b) Event
c) Stored function
d) Stored procedure
View Answer

Answer: b
Explanation: The MySQL version 5.1.6 and above has an event scheduler. It enables to perform time activated database operations. An event is a stored program that is associated with a schedule.

7. The line used to turn on the event scheduler is ______________
a) event_scheduler = ON
b) eventscheduler = ON
c) event_scheduler_ON
d) events_scheduler_ON
View Answer

Answer: a
Explanation: The line ‘event_scheduler = ON’ is put in the option file that the server reads. The event scheduler does not run by default. It must be turned on if events are to used in the database.
advertisement

8. What is the creation of a stored program similar to?
a) Trigger
b) Event
c) View
d) Table
View Answer

Answer: c
Explanation: When a stored program is created, an object is created that is to be executed later. This also the case when a view is defined: It sets up a SELECT statement intended for later invocation.

9. When the security context enables carefully written stored programs to be set up that provide controlled access to tables for users, it is called __________
a) bad
b) good
c) illegal
d) fare
View Answer

Answer: b
Explanation: The security context is good if it enables carefully written stored programs to be set up that provide controlled access to tables for users who are not able to access them directly.
advertisement

10. What is the maximum number of indexes on MyISAM table?
a) 0
b) 1
c) 2
d) more than 1
View Answer

Answer: d
Explanation: In MySQL, for a MyISAM table, there can be more than one indexes. The data rows of the MyISAM table are stored in a data file and the index values are stored in a separate index file.

Sanfoundry Global Education & Learning Series – MySQL Database.

To practice all areas of MySQL Database, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.