Test: Mid Term Exam Semester 1 - Part I
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
	The Mid Term Exam for Semester 1 is presented to you as two exams. This is Part I of the Mid Term Exam for Semester 1.	
	Section 1
					
		1. 	SQL is a common access language for many types of databases, including Oracle. True or False? 	Mark for Review 
(1) Points
					
			
	True (*)
	
			
	False
	
					
				
Correct		Correct
	
					
		2. 	Which of the following statements about PL/SQL and SQL is true? 	Mark for Review 
(1) Points
					
			
	PL/SQL and SQL are both ANSI-compliant.
	
			
	PL/SQL and SQL can be used with many types of databases, including Oracle.
	
			
	PL/SQL and SQL are both Oracle proprietary programming languages.
	
			
	PL/SQL allows basic program logic and control flow to be combined with SQL statements. (*)
	
					
				
Correct		Correct
	
					
		3. 	PL/SQL extends SQL by including all of the following except: 	Mark for Review 
(1) Points
					
			
	variables
	
			
	conditional statements
	
			
	reusable program units
	
			
	constants
	
			
	nonprocedural constructs (*)
	
					
				
Correct		Correct
	
					
		4. 	PL/SQL can be used not only with an Oracle database, but also with any kind of relational database. True or False? 	Mark for Review 
(1) Points
					
			
	True
	
			
	False (*)
	
					
				
Correct		Correct
	
					
		5. 	Which of the following statements about exception handling in PL/SQL is false? 	Mark for Review 
(1) Points
					
			
	You can prepare for database exceptions by creating exception handlers.
	
			
	You can prepare for application exceptions by creating exception handlers.
	
			
	Exception handling code tells your program what to do when an error is encountered.
	
			
	Exception handling code can be grouped together in a PL/SQL block.
	
			
	None of the above (*)
	
					
				
Correct		Correct
	
					
		6. 	Which of the following can you use PL/SQL to do? 	Mark for Review 
(1) Points
					
			
	Update data (DML)
	
			
	Develop Web applications using the Web Application Toolkit
	
			
	Manage database security
	
			
	Create customized reports
	
			
	All of the above (*)
	
					
				
Correct		Correct
	
					
		7. 	Which statements are optional in a PL/SQL block? (Choose two.) 	Mark for Review 
(1) Points
					
			(Choose all correct answers)	
					
			
	DECLARE (*)
	
			
	BEGIN
	
			
	EXCEPTION (*)
	
			
	END;
	
					
				
Correct		Correct
	
					
		8. 	What kind of block is defined by the following PL/SQL code?

BEGIN
    DBMS_OUTPUT.PUT_LINE('My first quiz');
END;
	Mark for Review 
(1) Points
					
			
	procedure
	
			
	subroutine
	
			
	function
	
			
	anonymous (*)
	
					
				
Correct		Correct
	
					
		9. 	Which PL/SQL block type must return a value? 	Mark for Review 
(1) Points
					
			
	Anonymous
	
			
	Function (*)
	
			
	Procedure
	
					
				
Correct		Correct
	
					
		10. 	Which of the following tools can NOT be used to develop and test PL/SQL code? 	Mark for Review 
(1) Points
					
			
	Oracle Jdeveloper
	
			
	Oracle Application Express
	
			
	Oracle JSQL (*)
	
			
	Oracle iSQL*Plus
	
					
				
Incorrect		Incorrect. Refer to Section 1. 
	Section 1
					
		11. 	Every PL/SQL anonymous block must start with the keyword DECLARE. True or False? 	Mark for Review 
(1) Points
					
			
	True
	
			
	False (*)
	
					
				
Correct		Correct
	
					
		12. 	What is the purpose of using DBMS_OUTPUT.PUT_LINE in a PL/SQL block? 	Mark for Review 
(1) Points
					
			
	To perform conditional tests
	
			
	To allow a set of statements to be executed repeatedly
	
			
	To display results to check if our code is working correctly (*)
	
			
	To store new rows in the database
	
					
				
Correct		Correct
	
					
		13. 	Which component of Oracle Application Express is used to enter and run SQL statements and PL/SQL blocks? 	Mark for Review 
(1) Points
					
			
	Application Builder
	
			
	SQL Workshop (*)
	
			
	Utilities
	
			
	Object Browser
	
					
				
Correct		Correct
	
					
					
	Section 2
					
		14. 	Identify which of the following assignment statements are valid. (Choose three.) 	Mark for Review 
(1) Points
					
			(Choose all correct answers)	
					
			
	v_last_name := Chandra;
	
			
	v_blackout_date := '31-DEC-2006'; (*)
	
			
	v_population := 333444; (*)
	
			
	v_music_type := 'ROCK'; (*)
	
					
				
Correct		Correct
	
					
		15. 	Variables can be assigned a value in both the Executable and Declaration sections of a PL/SQL program. True or False? 	Mark for Review 
(1) Points
					
			
	True (*)
	
			
	False
	
					
				
Correct		Correct
	
					
		16. 	Evaluate the following declaration. Determine whether or not it is legal.

DECLARE
maxsalary NUMBER(7) = 5000;
	Mark for Review 
(1) Points
					
			
	Correct.
	
			
	Not correct. (*)
	
					
				
Correct		Correct
	
					
		17. 	Is the following variable declaration correct or not ?

DECLARE
display_qty CONSTANT NUMBER;
	Mark for Review 
(1) Points
					
			
	Correct.
	
			
	Not correct. (*)
	
					
				
Correct		Correct
	
					
		18. 	Assignment statements can continue over several lines in PL/SQL. True or False? 	Mark for Review 
(1) Points
					
			
	True (*)
	
			
	False
	
					
				
Correct		Correct
	
					
		19. 	A variable must have a value if NOT NULL is specified. True or False? 	Mark for Review 
(1) Points
					
			
	True (*)
	
			
	False
	
					
				
Correct		Correct
	
					
		20. 	Which of the following should NOT be used as the name of a variable? 	Mark for Review 
(1) Points
					
			
	A table name.
	
			
	A table column name. (*)
	
			
	The database name.
	
					
				
Correct		Correct 
	Section 2
					
		21. 	Which of the following declarations is invalid? 	Mark for Review 
(1) Points
					
			
	v_count PLS_INTEGER:=0;
	
			
	college_name VARCHAR2(20):='Harvard';
	
			
	v_pages CONSTANT NUMBER; (*)
	
			
	v_start_date DATE := sysdate+1;
	
					
				
Correct		Correct
	
					
		22. 	Which of the following are disadvantages of implicit data type conversions? (Choose two.) 	Mark for Review 
(1) Points
					
			(Choose all correct answers)	
					
			
	The code is harder to read and understand (*)
	
			
	You cannot store alphabetic characters in a variable of data type NUMBER
	
			
	If Oracle changes the conversion rules in the future, your code may not work any more (*)
	
			
	Oracle cannot implicitly convert a number value to a character string
	
					
				
Correct		Correct
	
					
		23. 	The implicit data type conversion at Point A may not work correctly. Why not?

DECLARE
    v_mydate DATE;
BEGIN
    V_MYDATE := '29-Feb-04'; -- Point A
END;
	Mark for Review 
(1) Points
					
			
	There are only 28 days in February
	
			
	Oracle cannot implicitly convert a character string to a date, even if the string contains a valid date value
	
			
	If the database language is not English, 'Feb' has no meaning. (*)
	
			
	V_MYDATE has been entered in uppercase
	
					
				
Incorrect		Incorrect. Refer to Section 2.
	
					
		24. 	PL/SQL can convert a VARCHAR2 value containing alphabetic characters to a NUMBER value. True or False? 	Mark for Review 
(1) Points
					
			
	True
	
			
	False (*)
	
					
				
Correct		Correct
	
					
		25. 	TO_NUMBER, TO_CHAR, and TO_DATE are all examples of: 	Mark for Review 
(1) Points
					
			
	Implicit conversion functions
	
			
	Explicit conversion functions (*)
	
			
	Character functions
	
			
	Operators
	
					
				
Correct		Correct
	
					
		26. 	Examine the following code:

1 DECLARE
2 x NUMBER;
3 BEGIN
4 x:= '300';
5 END;

After line 4, what is the value of x?
	Mark for Review 
(1) Points
					
			
	'300'
	
			
	300 (*)
	
			
	NULL
	
					
				
Correct		Correct
	
					
		27. 	Which of the following are valid assignment statements? (Choose two.) 	Mark for Review 
(1) Points
					
			(Choose all correct answers)	
					
			
	v_string = 'Hello';
	
			
	v_string := Hello;
	
			
	v_number := 17 + 34; (*)
	
			
	v_string := 'Hello'; (*)
	
			
	v_date := 28-DEC-06;
	
					
				
Incorrect		Incorrect. Refer to Section 2.
	
					
		28. 	Single row character functions are valid SQL functions in PL/SQL. True or False? 	Mark for Review 
(1) Points
					
			
	True (*)
	
			
	False
	
					
				
Correct		Correct
	
					
		29. 	The DECODE function is available in PL/SQL procedural statements. True or False? 	Mark for Review 
(1) Points
					
			
	True
	
			
	False (*)
	
					
				
Correct		Correct
	
					
		30. 	Delimiters are _____ that have special meaning to the Oracle database. 	Mark for Review 
(1) Points
					
			
	identifiers
	
			
	variables
	
			
	symbols (*)
	
					
				
Correct		Correct 
	Section 2
					
		31. 	Reserved words can be used as identifiers. True or False? 	Mark for Review 
(1) Points
					
			
	True
	
			
	False (*)
	
					
				
Correct		Correct
	
					
		32. 	Which statements about lexical units are true? (Choose two.) 	Mark for Review 
(1) Points
					
			(Choose all correct answers)	
					
			
	They are named objects stored in the database
	
			
	They are the building blocks of every PL/SQL program (*)
	
			
	They are optional but can make a PL/SQL block execute faster
	
			
	They are sequences of characters including letters, digits, tabs, returns and symbols (*)
	
					
				
Correct		Correct
	
					
		33. 	When an exception occurs within a PL/SQL block, the remaining statements in the executable section of the block are skipped. True or False? 	Mark for Review 
(1) Points
					
			
	True (*)
	
			
	False
	
					
				
Correct		Correct
	
					
		34. 	What will be displayed when the following code is executed?

DECLARE
    varA NUMBER := 12;
BEGIN
    DECLARE
       varB NUMBER := 8;
    BEGIN
       varA := varA + varB;
    END;
    DBMS_OUTPUT.PUT_LINE(varB);
END;
	Mark for Review 
(1) Points
					
			
	8
	
			
	12
	
			
	Nothing, the block will fail with an error (*)
	
			
	20
	
			
	VarB
	
					
				
Correct		Correct
	
					
		35. 	Examine the following code. At Line A, we want to assign a value of 22 to the outer block's variable v_myvar. What code should we write at Line A?

<<outer_block>>
DECLARE
    v_myvar NUMBER;
BEGIN
    <<inner_block>>
    DECLARE
       v_myvar NUMBER := 15;
    BEGIN
       -- Line A
    END;
END;
	Mark for Review 
(1) Points
					
			
	outer_block.v_myvar := 22; (*)
	
			
	v_myvar := 22;
	
			
	<<outer_block>>.v_myvar := 22;
	
			
	v_myvar(outer_block) := 22;
	
			
	We cannot reference the outer block's variable because both variables have the same name
	
					
				
Correct		Correct
	
					
		36. 	When nested blocks are used, which blocks can or must be labeled? 	Mark for Review 
(1) Points
					
			
	The inner block must be labeled, the outer block can be labeled.
	
			
	Both blocks must be labeled
	
			
	Nested blocks cannot be labeled
	
			
	The outer block must be labeled if it is to be referred to in the inner block. (*)
	
					
				
Correct		Correct
	
					
		37. 	Examine the following code. Line A causes an exception. What will be displayed when the block is executed?

DECLARE
    var_a NUMBER := 6;
    var_b DATE;
BEGIN
    var_a := var_a * 2;
    var_b := '28 December 2006'; -- Line A
    var_a := var_a * 2;
EXCEPTION
    WHEN OTHERS THEN
       DBMS_OUTPUT.PUT_LINE(var_a);
END;
	Mark for Review 
(1) Points
					
			
	12 (*)
	
			
	24
	
			
	6
	
			
	Nothing will be displayed
	
					
				
Correct		Correct
	
					
		38. 	Which of these are PL/SQL data types? (Choose three.) 	Mark for Review 
(1) Points
					
			(Choose all correct answers)	
					
			
	Scalar (*)
	
			
	Identifier
	
			
	Delimiter
	
			
	Composite (*)
	
			
	LOB (*)
	
					
				
Correct		Correct
	
					
		39. 	A movie is an example of which category of data type? 	Mark for Review 
(1) Points
					
			
	Scalar
	
			
	Composite
	
			
	Reference
	
			
	LOB (*)
	
					
				
Correct		Correct
	
					
		40. 	A collection is a composite data type. True or False? 	Mark for Review 
(1) Points
					
			
	True (*)
	
			
	False
	
					
				
Correct		Correct
	
Section 3
					
		41. 	The following anonymous block of code is run:

BEGIN
    INSERT INTO countries (id, name)
    VALUES ('XA', 'Xanadu');
    INSERT INTO countries (id, name)
    VALUES ('NV','Neverland');
    COMMIT;
    COMMIT;
    ROLLBACK;
END;

What happens when the block of code finishes?
	Mark for Review 
(1) Points
					
			
	You have nothing new; the last ROLLBACK undid the INSERTs.
	
			
	You have the rows added twice; there are four new rows.
	
			
	You have the two new rows added. (*)
	
			
	You get an error; you cannot COMMIT twice in a row.
	
					
				
Correct		Correct
	
					
		42. 	The following anonymous block of code is run:

BEGIN
    INSERT INTO countries (id, name)
    VALUES ('XA', 'Xanadu');
    SAVEPOINT XA;
    INSERT INTO countries (id, name)
    VALUES ('NV','Neverland');
    COMMIT;
    ROLLBACK TO XA;
END;

What happens when the block of code finishes?
	Mark for Review 
(1) Points
					
			
	No data is inserted and no errors occur.
	
			
	No data is inserted and an error occurs
	
			
	Two rows are inserted and no errors occur.
	
			
	Two rows are inserted and an error occurs. (*)
	
					
				
Correct		Correct
	
					
		43. 	Which is the correct way to erase one row from a table? 	Mark for Review 
(1) Points
					
			
	REMOVE employee_id=100
FROM employees;

	
			
	DROP TABLE employees
WHERE employee_id=100;

	
			
	TRUNCATE employees
WHERE employee_id=100;

	
			
	DELETE FROM employees
WHERE employee_id=100;

(*)
	
					
				
Correct		Correct
	
					
		44. 	Which SQL statement can NOT use an implicit cursor? 	Mark for Review 
(1) Points
					
			
	A DELETE statement
	
			
	An UPDATE statement
	
			
	A SELECT statement that returns multiple rows (*)
	
			
	A SELECT statement that returns one row
	
					
				
Correct		Correct
	
					
		45. 	A PL/SQL block includes the following statement:

SELECT last_name INTO v_last_name
FROM employees
WHERE employee_id=100;

What is the value of SQL%ISOPEN immediately after the SELECT statement is executed?
	Mark for Review 
(1) Points
					
			
	True
	
			
	False (*)
	
			
	Null
	
			
	Error. That attribute does not apply for implicit cursors.
	
					
				
Incorrect		Incorrect. Refer to Section 3.
	
					
		46. 	Given this first section of code:

DECLARE
    v_result employees.salary%TYPE;
BEGIN

Which statement will always return exactly one value?
	Mark for Review 
(1) Points
					
			
	SELECT salary
INTO v_result
FROM employees;

	
			
	SELECT salary
INTO v_result
FROM employees
WHERE last_name ='Smith';

	
			
	SELECT salary
INTO v_result
FROM employees
WHERE department_id = 80;

	
			
	SELECT SUM(salary)
INTO v_result
FROM employees;

(*)
	
					
				
Correct		Correct
	
					
		47. 	Which one of these SQL statements can be directly included in a PL/SQL executable block? 	Mark for Review 
(1) Points
					
			
	SELECT last_name FROM employees
WHERE employee_id=100;

	
			
	DESCRIBE employees;

	
			
	UPDATE employees
SET last_name='Smith';

(*)
	
			
	DROP TABLE employees;

	
					
				
Correct		Correct
	
					
		48. 	The following code will return the last name of the employee whose employee id is equal to 100: True or False?

DECLARE
    v_last_name employees.last_name%TYPE;
    employee_id employees.employee_id%TYPE := 100;
BEGIN
    SELECT last_name INTO v_last_name
    FROM employees
    WHERE employee_id = employee_id;
END;

	Mark for Review 
(1) Points
					
			
	True
	
			
	False (*)
	
					
				
Correct		Correct
	
					
		49. 	Which one of these SQL statements can be directly included in a PL/SQL executable block? 	Mark for Review 
(1) Points
					
			
	DELETE FROM employees
WHERE department_id=60;

(*)
	
			
	SELECT salary FROM employees
WHERE department_id=60;

	
			
	CREATE TABLE new_emps (last_name VARCHAR2(10), first_name VARCHAR2(10));

	
			
	DROP TABLE locations;
	
					
				
Correct		Correct
	
					
		50. 	Which of the following is NOT a good guideline for retrieving data in PL/SQL? 	Mark for Review 
(1) Points
					
			
	Declare the receiving variables using %TYPE
	
			
	The WHERE clause is optional in nearly all cases. (*)
	
			
	Specify the same number of variables in the INTO clause as database columns in the SELECT clause.
	
			
	THE SELECT statement should fetch exactly one row.
	
					
				
Correct		Correct 