Sunteți pe pagina 1din 7

Test: Section 10 Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.

Section 10 Quiz
(Answer all questions in this section)

1. Package EMP_PACK contains two procedures, DEL_EMP and SHOW_EMP.


You want to write an anonymous block which invokes these procedures but you have
forgotten which parameters they use. Which of the following will give you this
information? Mark for Review
(1) Points

None of these.

DESCRIBE emp_pack
(*)

DESCRIBE emp_pack.del_emp
DESCRIBE emp_pack.show_emp

DESCRIBE del_emp
DESCRIBE show_emp

DESCRIBE emp_pack(del_emp, show_emp)

Correct Correct

2. Which of the following are good reasons for creating and using
Packages?
Related procedures, functions, and variables can be grouped together as a single
unit
We can recompile the package body without having to recompile the specification
We can create packages without needing any system privileges
The detailed package body code is invisible to the calling environment.
Mark for Review
(1) Points

A, B, C, and D

A and C

A, B, and D (*)

A and B
A, B, and C

Correct Correct

3. To be able to invoke a package subprogram from outside the


package, it must be declared in the package: Mark for Review
(1) Points

Body

Body and the specification (*)

Specification

None of these.

Correct Correct

4. The two parts of a package are stored as separate objects in the


database. True or False? Mark for Review
(1) Points

True (*)

False

Correct Correct

5. Which one of the following can NOT be part of a Package ? Mark


for Review
(1) Points

Functions

Triggers (*)

Procedures
Explicit cursors

Global variables

Correct Correct

Page 1 of 3 Next Summary

Test: Section 10 Quiz


Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.

Section 10 Quiz
(Answer all questions in this section)

6. A public function in a package is invoked from within a SQL


statement. The function's code can include a COMMIT statement. True or False?
Mark for Review
(1) Points

True

False (*)

Correct Correct

7. Examine the following package code:


CREATE OR REPLACE PACKAGE ol_pack IS
PROCEDURE subprog (p1 IN VARCHAR2, p2 IN NUMBER);
PROCEDURE subprog (param1 IN CHAR, param2 IN NUMBER);
FUNCTION subprog (param1 IN VARCHAR2, param2 IN NUMBER) RETURN DATE;
END ol_pack;

Which of the following calls will be successful? (Choose two.)

Mark for Review


(1) Points

(Choose all correct answers)

ol_pack.subprog(param1=>'Jane',param2=>30);

v_date := ol_pack.subprog('Jane',30); (*)

v_number := ol_pack.subprog(p1=>'Jane');
ol_pack.subprog('Jane',30); (*)

Incorrect Incorrect. Refer to Section 10 Lesson 3.

8. The following example package specification is valid to create a


data type ed_type that can be used in other subprograms. True or False?
CREATE OR REPLACE PACKAGE emp_dept_pkg
IS
TYPE ed_type IS RECORD (f_name employees.first_name%TYPE,
l_name employees.last_name%TYPE,
d_name departments.department_name
%TYPE);
PROCEDURE sel_emp_dept
(p_emp_id IN employees.employee_id%TYPE,
p_emp_dept_rec OUT ed_type);
END emp_dept_pkg;

Mark for Review


(1) Points

True (*)

False

Correct Correct

9. Which of the following statements about a package initialization


block is true? Mark for Review
(1) Points

It is an anonymous block at the end of a package body. (*)

It cannot contain any SQL statements.

It is executed automatically every time any global variable in the package is


referenced.

It is an anonymous block in the package specification.

It is a procedure in a package that must be invoked before the rest of the


package can be used.
Correct Correct

10. The following package is valid. True or False?


CREATE OR REPLACE PACKAGE exceptions_pkg IS
e_cons_violation EXCEPTION;
PRAGMA EXCEPTION_INIT (e_cons_violation, -2292);
e_value_too_large EXCEPTION;
PRAGMA EXCEPTION_INIT (e_value_too_large, -1438);
END exceptions_pkg;

Mark for Review


(1) Points

True (*)

False

Correct Correct

Previous Page 2 of 3 Next Summary

Test: Section 10 Quiz


Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.

Section 10 Quiz
(Answer all questions in this section)

11. We want to remove the specification (but not the body) of package
BIGPACK from the database. Which of the following commands will do this? Mark
for Review
(1) Points

DROP PACKAGE SPECIFICATION bigpack;

DROP PACKAGE bigpack;

None of these. (*)

DROP PACKAGE HEADER bigpack;

DROP PACKAGE bigpack SPECIFICATION;

Correct Correct
12. We need to declare a package variable named MYVAR, which can be
referenced by any subprogram in the package but can NOT be referenced from outside
the package. In the following code, where should MYVAR be declared?
CREATE OR REPLACE PACKAGE varpack IS
-- Point A
...
END varpack;
CREATE OR REPLACE PACKAGE BODY varpack IS
-- Point B
PROCEDURE varproc IS
-- Point C
BEGIN
...
END varproc;
PROCEDURE ...
...
-- Point D
END varpack;
Mark for Review
(1) Points

Point B or Point C, they will both work

Point C

Point A

Point D

Point B (*)

Correct Correct

13. Which one of the following queries would you use to see the
detailed code of a package called EMP_PKG? Mark for Review
(1) Points

SELECT text FROM user_source WHERE name = 'EMP_PKG' AND type = 'PACKAGE BODY'
ORDER BY line; (*)

SELECT text FROM all_source WHERE name = 'EMP_PKG' AND type = 'PACKAGE' ORDER
BY line;

SELECT source FROM user_packages WHERE name = 'EMP_PKG' AND type = 'PACKAGE
BODY' ORDER BY line;
SELECT text FROM user_source WHERE name = 'EMP_PKG' AND type = 'PACKAGE'
ORDER BY line;

Correct Correct

14. Package NEWPACK contains several procedures and functions,


including private function PRIVFUNC. From where can PRIVFUNC be invoked? (Choose
two.) Mark for Review
(1) Points

(Choose all correct answers)

From an anonymous block

From any private function in another package

From any function in NEWPACK (*)

From any public procedure in another package

From any procedure in NEWPACK (*)

Correct Correct

15. Your schema contains a package called EMP_PKG. You want to remove
the package body but not the specification. The correct syntax to do this is: DROP
BODY emp_pkg; True or False? Mark for Review
(1) Points

True

False (*)

Correct Correct

Previous Page 3 of 3 Summary