Вы находитесь на странице: 1из 10

1) Which of the following statements is false for the TIME data type: The TIME data type can

store elapsed time which may be negative. The TIME data type can store elapsed time which may be greater that 24 hours. The TIME data type actually stores the number of seconds elapsed since the beginning of 1970. 2) This SQL statement is valid "SELECT ID, Name FROM some_table ORDER BY Name WHERE ID < 100" True

False
Cannot be answered. 3) Given the following data: mysql> SELECT * FROM datum; col 1 2 4 3 3 3 6 rows in set (0.00 sec) Which of the following statements will exactly update one of the rows containing the value 3 to the value 6? UPDATE datum SET col=6 WHERE col=3 LIMIT 1

UPDATE datum SET col=6 WHERE FIRST(col=3)


SELECT FOR UPDATE WHERE col=3 SET col=6 ON_FIRST_OCCURANCE You can not update just one of the columns with value 3 with the given table structure 4) The table tablex contains the following data: mysql> SELECT * FROM tablex; col

A NULL B NULL NULL C 6 rows in set (0.00 sec) How many rows will be returned when the following statement is executed? SELECT DISTINCT col FROM tablex; 1 3 4 5 6 5) You issue a SELECT statement without an ORDER BY clause and it returns some rows. But in what order are the resulting rows guaranteed to be? in increasing order there is no guaranteed order in random order in the order inserted in decreasing order 6) For the following tables: Users: Field Id phonenumber Type int(10) Null Default No auto_increment

varchar(16) No

Purchases: Field id Type int(10) Null Default Yes NULL

user product date

int(10) int(10) datetime

Yes Yes Yes 0000-00-00 00:00:00

Products: Field id name Type int(10) varchar(32) Null Yes Yes Default

Which query is needed to get the following result: USER PRODUCT DATE 2008-01-28 00:00:00 2008-01-24 00:00:00 214748364 Asphalt 3 7 214748364 Rayman Raving 7 Rabbids

SELECT users.phonenumber AS 'USER', products.name AS 'PRODUCT', purchases.date AS 'DATE' FROM `purchases` INNER JOIN users WHERE purchases.id = users.id INNER JOIN products WHERE purchases.product = products.id SELECT users.phonenumber AS 'USER', products.name AS 'PRODUCT', purchases.date AS 'DATE' FROM `purchases` INNER JOIN users ON purchases.id = users.id INNER JOIN products ON purchases.product = products.id SELECT users.phonenumber AS 'USER', products.name AS 'PRODUCT', purchases.date AS 'DATE' FROM `purchases` INNER JOIN users ON purchases.user = users.id INNER JOIN products ON purchases.product = products.id None of the above 7) For table structures for users and purchases, listed in the previous question. Which query must be used to retrieve each purchase's id, user and date, and also users with no purchases? SELECT users.id, users.phonenumber, purchases.date FROM `purchases` RIGHT JOIN users on purchases.user = users.id SELECT users.id, users.phonenumber, purchases.date FROM `purchases` LEFT JOIN users on purchases.user = users.id SELECT users.id, users.phonenumber, purchases.date FROM `purchases` INNER JOIN users on purchases.user = users.id SELECT users.id, users.phonenumber, purchases.date FROM `purchases` CROSS JOIN users on purchases.user = users.id

Either of the above None of the above 8) What does the following query return: SELECT id FROM purchases WHERE product IN (SELECT id FROM products WHERE name LIKE "%B%") The ids for product for which their name contains a "B" The ids for purchases for which the purchased product contains a "B" The ids for purchases for which the purchased product does not contain a "B" The ids for product for which their name start with "B" None of the above 9) mysql> DESCRIBE Country; Field Code Name Capital Type char(3) char(52) int(11) YES NULL Null Key PRI Default Extra

3 rows in set (0.00 sec) mysql> DESCRIBE City; Field Id Name Country Type int(11) char(35) char(3) 0 Null Key Default Extra PRI NULL auto_increment

Population int(11) 4 rows in set (0.00 sec)

The tables are related through Capital in Country to Id in City and Code in Country to Country in City.

Which rows will the following query return? SELECT Country.Name, Capital FROM City, Country WHERE Capital = Id; It will return all rows from the Country table that have corresponding Capitals in the City table It will return the number of rows in Country multiplied by the number of rows in City It will return all rows from the Country table, with or without corresponding Capitals in City It will return all rows from the City table with or without corresponding Capital entries in the Country table No rows, it will result in an error 10) What does the following query return: SELECT (NOW() + INTERVAL 2 MONTH) A datetime string for the date and time two months from the moment the query is executed A date string for the date two months from the moment the query is executed SQL Error 11) Which of the following will select only those values in column FirstName from the personnel table that start with the letter 'C'? SELECT FirstName FROM personnel WHERE FirstName LIKE 'C' SELECT FirstName FROM personnel WHERE FirstName STARTS_WITH 'C' SELECT FirstName FROM personnel WHERE FirstName LIKE 'C%' SELECT FirstName FROM personnel WHEN FirstName STARTS 'C%' SELECT FirstName FROM personnel WHERE FirstName like 'C*' SELECT FirstName FROM personnel WHERE FirstName ^C 12) Assuming the table City does not exists when the following statements are executed: CREATE TABLE City (name CHAR(25)) ENGINE=INNODB INSERT INTO City VALUES ('Rome') BEGIN INSERT INTO City VALUES ('Paris') ROLLBACK

What will be the contents of the table City after all the statements are completed? ('Paris') ('Rome') ('Paris','Rome') NULL The table will be empty 13) If $son_age is minor than $father_age , which one of the next options will be printed? if($father_age==$son_age){ echo " son_age is not equal to father_age "; } if($father_age !> $son_age){ echo " son_age is minor than father_age "; } if (($son_age==$father_age) or ($son_age<=$father_age)){ echo "son_age is minor than father_age"; } if($son_age>=$father_age){ echo "son_age is minor than father_age "; } 14) You have to print numbers from 1 to 10 using the statement for(), How should you do that? for($=0 to $=10){ echo $i; } for($i=1 ; $i<=10;$i++){ echo $i; } for($i=0;$i<10; ){ echo $i; $i++;} for($i=0;$i<10){ echo $i; $i++;} 15) What does the following regular expression look for: ^(//|/*).*(*/)?$ lines that contain // and /* */ comment types lines that do not contain comments (both // and /* */ type) both a) and b) none of the above all statements 16) The constructor for class A takes a $name parameter, class B extends class A, and it's constructor takes no parameters. What is the result of doing the following: $object = new B();

$object does not have a 'name' attribute $object has a 'name' attribute, but it is unset a warning is thrown a fatal error is thrown none of the above 17) Which of the following functions define a global variable with value = 5? function definevariable (){ var global $a=5; }; function definevariable (){ $a=5; }; function definevariable (){ global $a=5; }; function definevariable (){ a=5; }; function definevariable (){ var $a=5; }; 18) How do I define a constant with the value= 10 in PHP? constant ($MICONSTANT=10); define ("$MICONSTANT"=10); global_constant($MICONSTANT=10); set_constant ($MICONSTANT=10); define ("MICONSTANT",10); 19) The statement "require": Ask for the parameters sent by a form Returns the parameters from the configuration Ask for the configuration parameters Authorize the statement sent by the superuser Includes a file inside the code 20) Which of the following statements will display the content of the array $my_array? print_r $my_array; echo_array ($my_array);

echo ($my_array); print ($my_array); none of the listed answers 21) For the following function: function isUser($user) { If ($user == "root") { return "false"; } else { return true; } } What is outputted in the following code: $user = "root"; if (isUser($user)) { Echo "User Allowed"; } else { Echo "User Denied"; } User Allowed User Denied there's no output a warning is issued 22) Which of the next statement returns the quantity of elements in the array $foo? elems($foo); recordcount($foo); rec($foo); count($foo); each($foo); 23) For an employee php class which runs on a php4 interpreter and contains a getName() method that receives no arguments and returns a string, how must it be declared in the class. public function String getName(void){}

public var getName(){} function getName(null){} public function getName(void){} function getName(){} 24) If $value=1, which of the following expressions will not give as result $value=2? $value=$value+$value; $value==$value+1; $value=1+1; $value+=$value; $value++; 25) If we have next script: $sql = SELECT * from Countries; Assuming the connection to the database is active and the table exists, Which is the correct sentence if we want to run the script stored in $sql?

echo $sql; query ($sql); mysql_query ($sql); run_mysql ($sql); db_query_run ($sql); 26) How would you overload a class method in php 4? by declaring the method twice, with different arguments by declaring the method once, with optional arguments (those with default values) by extending the class that contains the method and adding a new one it's not possible 27) What is the result of a script containing the following line, if the file to include does not exist.

require("file.php");

a fatal error is issued, script stops execution no warning is issued, the code depending on that file's code will not work properly there's no change in the script's execution a warning is issued, and the code depending on that file's code will not work properly the file is created on the fly 28) Which of the following keywords are not part of the php4 language? void const implements as all of the above

Вам также может понравиться