diff --git a/mysql/mysql-quiz.md b/mysql/mysql-quiz.md index ef117eae16..21c060484c 100755 --- a/mysql/mysql-quiz.md +++ b/mysql/mysql-quiz.md @@ -1199,3 +1199,187 @@ SELECT name FROM Students WHERE exam_score > 90; - [ ] SEARCH - [x] SELECT - [ ] EXTRACT + + + +#### Q125. Which MySQL function would you use to get the current date and time? + +- [ ] GETDATE() +- [ ] CURRENTTIME() +- [x] NOW() +- [ ] DATETIME() + +#### Q126. In MySQL, which statement is used to add a new column to an existing table? + +- [ ] MODIFY TABLE +- [ ] UPDATE TABLE +- [x] ALTER TABLE +- [ ] CHANGE TABLE + +#### Q127. What is the purpose of the LIMIT clause in a MySQL SELECT statement? + +- [ ] To limit the number of tables that can be joined +- [x] To restrict the number of rows returned by the query +- [ ] To limit the number of columns that can be selected +- [ ] To restrict the query execution time + +#### Q128. Which MySQL command is used to show all databases on the server? + +- [ ] LIST DATABASES; +- [ ] DISPLAY DATABASES; +- [x] SHOW DATABASES; +- [ ] SELECT DATABASES; + +#### Q129. What does the UNSIGNED keyword do when used in a column definition? + +- [ ] It makes the column accept only positive numbers +- [ ] It makes the column accept only whole numbers +- [x] It doubles the maximum value that can be stored in the column +- [ ] It makes the column accept only text data + +#### Q130. Which MySQL function would you use to find the length of a string? + +- [ ] SIZE() +- [x] LENGTH() +- [ ] LEN() +- [ ] STRLEN() + +#### Q131. What is the purpose of the AUTO_INCREMENT attribute in MySQL? + +- [ ] To automatically update the column value when the row is modified +- [ ] To automatically decrease the column value by 1 for each new row +- [x] To automatically generate a unique identity for new rows +- [ ] To automatically set the column to the current timestamp + +#### Q132. Which MySQL statement is used to remove a table from a database? + +- [ ] REMOVE TABLE +- [ ] DELETE TABLE +- [x] DROP TABLE +- [ ] ERASE TABLE + +#### Q133. What does the LIKE operator do in a WHERE clause? + +- [ ] It compares two values for exact equality +- [x] It searches for a specified pattern in a column +- [ ] It checks if a value is NULL +- [ ] It performs mathematical comparisons + +#### Q134. Which MySQL function returns the number of rows affected by an INSERT, UPDATE, or DELETE statement? + +- [ ] AFFECTED_ROWS() +- [ ] COUNT_CHANGES() +- [ ] ROW_COUNT() +- [x] FOUND_ROWS() + +#### Q135. What is the purpose of the HAVING clause in MySQL? + +- [ ] To join multiple tables +- [ ] To sort the result set +- [x] To specify a search condition for a group or an aggregate +- [ ] To limit the number of rows returned + +#### Q136. Which MySQL statement is used to grant privileges to a user? + +- [ ] ADD PRIVILEGES +- [ ] SET PRIVILEGES +- [x] GRANT +- [ ] ALLOW + +#### Q137. What does the IFNULL() function do in MySQL? + +- [ ] It checks if a value is not NULL +- [x] It returns a specified value if the expression is NULL +- [ ] It sets a column value to NULL +- [ ] It removes NULL values from a result set + +#### Q138. Which MySQL command is used to show the current user and host? + +- [ ] SHOW USER; +- [ ] CURRENT_USER(); +- [ ] WHO AM I; +- [x] SELECT USER(); + +#### Q139. What is the purpose of the EXPLAIN statement in MySQL? + +- [ ] To provide documentation for a stored procedure +- [ ] To show the structure of a table +- [x] To show the execution plan of a SELECT statement +- [ ] To explain the meaning of an error message + +#### Q140. Which MySQL function would you use to round a number to the nearest integer? + +- [ ] CEIL() +- [ ] FLOOR() +- [x] ROUND() +- [ ] INT() + +#### Q141. What does the UNIQUE constraint do in MySQL? + +- [ ] It ensures that the column cannot contain NULL values +- [x] It ensures that all values in the column are different +- [ ] It automatically increments the value for each new row +- [ ] It sets a default value for the column + +#### Q142. Which MySQL statement is used to create an index on a table? + +- [ ] ADD INDEX +- [x] CREATE INDEX +- [ ] MAKE INDEX +- [ ] INDEX TABLE + +#### Q143. What is the purpose of the COALESCE() function in MySQL? + +- [ ] To combine multiple columns into one +- [ ] To check if all values in a list are equal +- [x] To return the first non-NULL value in a list +- [ ] To count the number of non-NULL values in a list + +#### Q144. Which MySQL command is used to start a transaction? + +- [ ] BEGIN TRANSACTION +- [ ] START TRANSACTION +- [ ] INIT TRANSACTION +- [x] BEGIN + +#### Q145. What does the CONCAT() function do in MySQL? + +- [ ] It adds numbers together +- [x] It joins two or more strings together +- [ ] It combines multiple rows into one +- [ ] It merges two tables + +#### Q146. Which MySQL statement is used to create a stored procedure? + +- [ ] MAKE PROCEDURE +- [ ] ADD PROCEDURE +- [x] CREATE PROCEDURE +- [ ] DEFINE PROCEDURE + +#### Q147. What is the purpose of the REGEXP operator in MySQL? + +- [ ] To perform mathematical operations +- [ ] To join multiple tables +- [x] To perform pattern matching using regular expressions +- [ ] To check if a value exists in a subquery + +#### Q148. Which MySQL function would you use to get the current user's username? + +- [ ] CURRENT_USER() +- [ ] USERNAME() +- [x] USER() +- [ ] SYSTEM_USER() + +#### Q149. What does the DISTINCT keyword do in a SELECT statement? + +- [ ] It sorts the result set in ascending order +- [ ] It limits the number of rows returned +- [x] It removes duplicate rows from the result set +- [ ] It selects only specific columns from the table + +#### Q150. Which MySQL statement is used to delete all rows from a table without deleting the table itself? + +- [ ] DELETE TABLE +- [ ] REMOVE ALL FROM +- [ ] DROP TABLE +- [x] TRUNCATE TABLE diff --git a/php/php-quiz.md b/php/php-quiz.md index 0308f6bec5..e262682087 100755 --- a/php/php-quiz.md +++ b/php/php-quiz.md @@ -1570,6 +1570,7 @@ Explanation : 'false' evaluates to true since it is a string so the if condition - [x] continue + ### Q108. What is the output of this code? ```php @@ -1579,17 +1580,20 @@ $y = "2$y"; echo $x; ``` -- [ ] 5 -- [ ] 2 -- [x] 25 -- [ ] An error occurs + +- [ ] 5 +- [ ] 2 +- [x] 25 +- [ ] An error occurs ### Q109. Which function is used to check if a file exists in PHP? -- [ ] file_exists() -- [ ] is_file() -- [ ] file_check() -- [x] Both file_exists() and is_file() +- [ ] file_exists() +- [ ] is_file() +- [ ] file_check() +- [x] Both file_exists() and is_file() + + ### Q110. What does the following code output? @@ -1598,31 +1602,33 @@ $array = array(1, 2, 3, 4, 5); echo array_sum($array) / count($array); ``` -- [ ] 15 -- [x] 3 -- [ ] 5 -- [ ] An error occurs + +- [ ] 15 +- [x] 3 +- [ ] 5 +- [ ] An error occurs ### Q111. Which of the following is NOT a valid way to start a PHP session? -- [ ] session_start(); -- [ ] $\_SESSION = array(); -- [x] session_begin(); -- [ ] ini_set('session.auto_start', 1); +- [ ] session_start(); +- [ ] $_SESSION = array(); +- [x] session_begin(); +- [ ] ini_set('session.auto_start', 1); ### Q112. What is the purpose of the 'finally' block in a try-catch-finally structure? -- [ ] To handle exceptions that weren't caught in the catch block -- [ ] To define custom exceptions -- [x] To execute code regardless of whether an exception was thrown or caught -- [ ] To end the try-catch block +- [ ] To handle exceptions that weren't caught in the catch block +- [ ] To define custom exceptions +- [x] To execute code regardless of whether an exception was thrown or caught +- [ ] To end the try-catch block ### Q113. Which function would you use to remove HTML tags from a string? -- [ ] html_clean() -- [x] strip_tags() -- [ ] remove_html() -- [ ] sanitize_string() +- [ ] html_clean() +- [x] strip_tags() +- [ ] remove_html() +- [ ] sanitize_string() + ### Q114. What is the output of this code? @@ -1632,31 +1638,32 @@ $str[0] = "J"; echo $str; ``` -- [ ] Hello -- [x] Jello -- [ ] An error occurs -- [ ] H +- [ ] Hello +- [x] Jello +- [ ] An error occurs +- [ ] H ### Q115. Which of the following is NOT a magic method in PHP? -- [ ] \_\_construct() -- [ ] \_\_destruct() -- [ ] \_\_toString() -- [x] \_\_change() +- [ ] __construct() +- [ ] __destruct() +- [ ] __toString() +- [x] __change() ### Q116. What does the 'yield' keyword do in PHP? -- [ ] It's used to define abstract methods -- [ ] It's used to pause the execution of a function -- [x] It's used to define generator functions -- [ ] It's used to force garbage collection +- [ ] It's used to define abstract methods +- [ ] It's used to pause the execution of a function +- [x] It's used to define generator functions +- [ ] It's used to force garbage collection ### Q117. Which function would you use to get the ASCII value of a character? -- [ ] ascii() -- [ ] char_to_ascii() -- [x] ord() -- [ ] ascii_val() +- [ ] ascii() +- [ ] char_to_ascii() +- [x] ord() +- [ ] ascii_val() + ### Q118. What is the output of this code? @@ -1667,31 +1674,32 @@ $c = array_combine($a, $b); print_r($c); ``` -- [ ] Array ( [0] => 1 [1] => 2 [2] => 3 ) -- [ ] Array ( [0] => one [1] => two [2] => three ) -- [x] Array ( [1] => one [2] => two [3] => three ) -- [ ] An error occurs +- [ ] Array ( [0] => 1 [1] => 2 [2] => 3 ) +- [ ] Array ( [0] => one [1] => two [2] => three ) +- [x] Array ( [1] => one [2] => two [3] => three ) +- [ ] An error occurs ### Q119. Which of the following is NOT a valid PHP comparison operator? -- [ ] === -- [ ] !== -- [ ] <> -- [x] => +- [ ] === +- [ ] !== +- [ ] <> +- [x] => ### Q120. What does the 'static' keyword do when used inside a function? -- [ ] It makes the function available globally -- [x] It preserves the value of the variable between function calls -- [ ] It prevents the function from being called more than once -- [ ] It makes the function run faster +- [ ] It makes the function available globally +- [x] It preserves the value of the variable between function calls +- [ ] It prevents the function from being called more than once +- [ ] It makes the function run faster ### Q121. Which function would you use to get the current timestamp in PHP? -- [ ] now() -- [ ] current_time() -- [x] time() -- [ ] timestamp() +- [ ] now() +- [ ] current_time() +- [x] time() +- [ ] timestamp() + ### Q122. What is the output of this code? @@ -1700,31 +1708,36 @@ $str = "abcdef"; echo substr($str, -2, 1); ``` -- [ ] f -- [x] e -- [ ] ef -- [ ] de + +- [ ] f +- [x] e +- [ ] ef +- [ ] de ### Q123. Which of the following is NOT a valid way to comment in PHP? -- [ ] // Single line comment -- [ ] /_ Multi-line comment _/ -- [ ] # Shell-style comment -- [x] ' Single quote comment +- [ ] // Single line comment +- [ ] /* Multi-line comment */ +- [ ] + + # Shell-style comment + +- [x] ' Single quote comment ### Q124. What does the 'instanceof' operator do in PHP? -- [ ] It checks if a variable is an instance of a class -- [ ] It creates a new instance of a class -- [ ] It checks if a class exists -- [x] It checks if an object is an instance of a class or interface +- [ ] It checks if a variable is an instance of a class +- [ ] It creates a new instance of a class +- [ ] It checks if a class exists +- [x] It checks if an object is an instance of a class or interface ### Q125. Which function would you use to check if a variable is an array? -- [ ] is_array() -- [ ] array_check() -- [ ] typeof() -- [x] is_array() +- [ ] is_array() +- [ ] array_check() +- [ ] typeof() +- [x] is_array() + ### Q126. What is the output of this code? @@ -1739,31 +1752,33 @@ myTest(); echo $y; ``` -- [ ] 10 -- [ ] 5 -- [x] 15 -- [ ] An error occurs + +- [ ] 10 +- [ ] 5 +- [x] 15 +- [ ] An error occurs ### Q127. Which of the following is NOT a valid PHP array function? -- [ ] array_push() -- [ ] array_pop() -- [ ] array_shift() -- [x] array_delete() +- [ ] array_push() +- [ ] array_pop() +- [ ] array_shift() +- [x] array_delete() ### Q128. What does the 'final' keyword do when used before a class declaration? -- [ ] It makes the class abstract -- [x] It prevents the class from being inherited -- [ ] It makes the class static -- [ ] It makes all methods in the class private +- [ ] It makes the class abstract +- [x] It prevents the class from being inherited +- [ ] It makes the class static +- [ ] It makes all methods in the class private ### Q129. Which function would you use to get the length of a string in PHP? -- [ ] count() -- [ ] length() -- [x] strlen() -- [ ] size() +- [ ] count() +- [ ] length() +- [x] strlen() +- [ ] size() + ### Q130. What is the output of this code? @@ -1774,7 +1789,7 @@ $b = "World"; echo $a; ``` -- [ ] Hello -- [x] World -- [ ] HelloWorld -- [ ] An error occurs +- [ ] Hello +- [x] World +- [ ] HelloWorld +- [ ] An error occurs