Semester 1 Mid Term Exam Part 1 PDF
Semester 1 Mid Term Exam Part 1 PDF
Semester 1 Mid Term Exam Part 1 PDF
12. In which part of the PL/SQL block are declarations of variables defined?
Mark for Review (1) Points
Executable Exception Declarative (*) Definition Correct
Section 2 (Answer all questions in this section) 13. Assignment statements can c
ontinue over several lines in PL/SQL. True or False?
Mark for Review (1) Points
True (*) False Correct 14. Variables can be assigned a value in both the Executa
ble and Declaration sections of a PL/SQL program. True or False?
Mark for Review (1) Points
True (*) False Correct 15. When a variable is defined using the NOT NULL keyword
s, the variable must contain a value. True or False?
Mark for Review (1) Points
True (*) False Correct
16. When a variable is defined using the CONSTANT keyword, the value of the vari
able cannot change. True or False?
Mark for Review (1) Points
True (*) False Correct 17. ______ are meant to store large amounts of data.
Mark for Review (1) Points
Variables Scalar data types LOBs (*) Correct 18. Which statement most closely de
scribes "data type"?
Mark for Review (1) Points
It is the value of a variable. It specifies a storage format, constraints, and a
valid range of values for a variable. (*) It allows different kinds of data to
be stored in a single variable. It is used to test if errors have occurred. Corr
ect 19. A collection is a composite data type. True or False?
Mark for Review (1) Points
True (*) False Correct 20. Which good programming practice guideline would make
this code easier to read? DECLARE v_sal NUMBER(8,2); BEGIN SELECT salary INTO v_
sal
Mark for Review (1) Points
FROM employees WHERE employee_id = 100; UPDATE employees SET salary = v_sal; END
; Declaring variables using %TYPE Indenting each level of code (*) Using a consi
stent naming convention for variables Avoiding implicit data type conversions Co
rrect Section 2 (Answer all questions in this section) 21. Which of these are ex
amples of good programming practice? (Choose three.)
Mark for Review (1) Points
(Choose all correct answers) Declare two variables on each line of code. Use a N
OT NULL constraint when a variable must have a value (*) Use a clear and consist
ent naming convention for variables. (*) Declare variables with the same names a
s table columns. Do not rely on implicit data type conversions. (*) Correct 22.
Which of the following will help to make code easier to read?
Mark for Review (1) Points
Naming variables. Using %Type. Including comments in the code. (*) Incorrect. Re
fer to Section 2 Lesson 7. 23. Which of the following can be assigned to a Boole
an variable? 1. Null 2. False 3. True 4. 0 2 and 3
Mark for Review (1) Points
2, 3 and 4 1, 2 and 3 (*) 1, 2, 3 and 4 Correct 24. You need to declare a variab
le to hold a value which has been read from the SALARY column of the EMPLOYEES t
able. Which of the following is an advantage of declaring the variable as: emplo
yees.salary%TYPE ? It is shorter than coding NUMBER(8,2) If the SALARY column is
ALTERed later, the PL/SQL code need not be changed. (*) It executes much faster
than using NUMBER(8,2) It allows the software to perform implicit data type con
versions. Correct 25. A variable must have a value if NOT NULL is specified. Tru
e or False?
Mark for Review (1) Points
Mark for Review (1) Points
True (*) False Correct 26. What will be displayed when the following code is exe
cuted? DECLARE varA NUMBER := 12; BEGIN DECLARE varB NUMBER := 8; BEGIN varA :=
varA + varB; END; DBMS_OUTPUT.PUT_LINE(varB); END; 8 12 Nothing, the block will
fail with an error (*) 20 VarB
Mark for Review (1) Points
Correct 27. 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 mus
t 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 28. Examine the followin
g code. Line A causes an exception. What will be displayed when the block is exe
cuted? 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 DB
MS_OUTPUT.PUT_LINE(var_a); END; 12 (*) 24 6 Nothing will be displayed Correct 29
. PL/SQL does not look _________ in the child blocks.
Mark for Review (1) Points
Mark for Review (1) Points
Inward Upward Outward Downward (*) Correct
30. What will be displayed when the following block is executed? <<outer>> DECLA
RE v_myvar VARCHAR2(10) := 'Hello' ; BEGIN <<inner>> DECLARE v_myvar VARCHAR2(10
) := 'World'; BEGIN v_myvar := v_myvar || ' ' || outer.v_myvar; END; DBMS_OUTPUT
.PUT_LINE(inner.v_myvar); END; HelloWorld Hello World World The code will fail s
ince the inner variable is not within the scope of the outer block. (*) Correct
Section 2 (Answer all questions in this section) 31. TO_NUMBER, TO_CHAR, and TO_
DATE are all examples of:
Mark for Review (1) Points
Mark for Review (1) Points
Implicit conversion functions Explicit conversion functions (*) Character functi
ons Operators Correct 32. What is the output when the following program is execu
ted? set serveroutput on DECLARE a VARCHAR2(10) := '333'; b VARCHAR2(10) := '444
'; c PLS_INTEGER; d VARCHAR2(10); BEGIN c := TO_NUMBER(a) + TO_NUMBER(b); d := a
|| b; DBMS_OUTPUT.PUT_LINE(c); DBMS_OUTPUT.PUT_LINE(d); END;
Mark for Review (1) Points
Nothing. The code will result in an error. c=777 and d=333444 (*) c=777 and d=77
7 c=333444 and d=777 Correct 33. Which of the following are disadvantages of imp
licit data type conversions? (Choose two.)
Mark for Review (1) Points
(Choose all correct answers) The code is harder to read and understand (*) You c
annot store alphabetic characters in a variable of data type NUMBER If Oracle ch
anges the conversion rules in the future, your code may not work any more (*) Or
acle cannot implicitly convert a number value to a character string Correct 34.
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; Correct 35. PL/SQL ca
n convert a VARCHAR2 value containing alphabetic characters to a NUMBER value. T
rue or False?
Mark for Review (1) Points
True False (*) Correct
36. Examine the following code: 1 2 3 4 5 DECLARE x NUMBER; BEGIN x:= '300'; END
;
Mark for Review (1) Points
After line 4, what is the value of x? '300' 300 (*) NULL Correct 37. Examine the
following code. What is the final value of V_MYBOOL ? DECLARE v_mynumber NUMBER
; v_mybool BOOLEAN ; BEGIN v_mynumber := 6; v_mybool := (v_mynumber BETWEEN 10 A
ND 20); v_mybool := NOT (v_mybool); END; True (*) False Correct 38. When you use
a function to convert data types in a PL/SQL program, it is called ______ conve
rsion.
Mark for Review (1) Points
Mark for Review (1) Points
Explicit (*) Implicit TO_CHAR Correct 39. Reserved words can be used as identifi
ers. True or False?
Mark for Review (1) Points
True False (*) Correct 40. Delimiters are _____ that have special meaning to the
Oracle database.
Mark for Review (1) Points
identifiers variables symbols (*) Correct Section 2 (Answer all questions in thi
s section) 41. Valid identifiers begin with a
Mark for Review (1) Points
Number Letter (*) Special character Correct
Section 3 (Answer all questions in this section) 42. Which rows will be deleted
from the EMPLOYEES table when the following code is executed? DECLARE salary emp
loyees.salary%TYPE := 12000; BEGIN DELETE FROM employees WHERE salary > salary;
END; All rows whose SALARY column value is greater than 12000. All rows in the t
able.
Mark for Review (1) Points
No rows. (*) All rows whose SALARY column value is equal to 12000. Correct 43. T
he 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; empl
oyee_id employees.employee_id%TYPE := 100; BEGIN SELECT last_name INTO v_last_na
me FROM employees WHERE employee_id = employee_id; END; True False (*) Correct 4
4. Which one of these SQL statements can be directly included in a PL/SQL execut
able block?
Mark for Review (1) Points
Mark for Review (1) Points
DELETE FROM employees WHERE department_id=60; (*) SELECT salary FROM employees W
HERE department_id=60; CREATE TABLE new_emps (last_name VARCHAR2(10), first_name
VARCHAR2(10)); DROP TABLE locations; Correct 45. A variable is declared as: DEC
LARE v_holdit employees.last_name%TYPE; BEGIN ... Which of the following is a co
rrect use of the INTO clause? SELECT * INTO v_holdit FROM employees;
Mark for Review (1) Points
SELECT last_name INTO v_holdit FROM employees; SELECT last_name INTO v_holdit FR
OM employees WHERE employee_id=100; (*) SELECT salary INTO v_holdit FROM employe
es WHERE employee_id=100; Incorrect. Refer to Section 3 Lesson 2. 46. 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 47. Assume there are 5
employees in Department 10. What happens when the following statement is execute
d? UPDATE employees SET salary=salary*1.1; All employees get a 10% salary increa
se. (*) No rows are modified because you did not specify "WHERE department_id=10
" A TOO_MANY_ROWS exception is raised. An error message is displayed because you
must use the INTO clause to hold the new salary. Correct 48. There are no emplo
yees in Department 77. What will happen when the following block is executed? BE
GIN DELETE FROM employees WHERE department_id=77; DBMS_OUTPUT.PUT_LINE(SQL%ROWCO
UNT) END;
Mark for Review (1) Points
Mark for Review (1) Points