This set of PL/SQL Multiple Choice Questions & Answers (MCQs) focuses on “PL/SQL Packages”.
1. Packages are schema objects.
a) True
b) False
View Answer
Explanation: A Package is a schema object that groups logically related PL/SQL types, variables, and subprograms. A schema is a collection of logical structures of data, or schema objects. A schema object can be created and manipulated via SQL.
2. A package is divided into how many parts?
a) 1
b) 2
c) 3
d) 4
View Answer
Explanation: A package consists of 2 parts – Package specification and Package definition/body. Package specification is just the interface of the package and is used to just define the package and its subparts. The package body contains the working of various parts of the package.
3. Which of the following parts are mandatory to include in a package?
a) Package Specification
b) Package Definition
c) Neither package specification nor package definition
d) Both package specification and package definition
View Answer
Explanation: Both parts of a package i.e. Package specification and Package definition are mandatory to include when creating a package in PL/SQL.Package specification is like the interface for the package and the package definition contains the working of the objects.
4. All objects placed within the package specification are known as which objects?
a) Private Objects
b) Protected Objects
c) Public Objects
d) Normal Objects
View Answer
Explanation: All objects placed within the package specification are known as public objects. Package specification only contains information about the package and no actual code for subprograms, so, these objects are just used for declaration purpose.
5. All objects placed within the package definition are known as which objects?
a) Private Objects
b) Protected Objects
c) Public Objects
d) Normal Objects
View Answer
Explanation: All objects placed within the package definition are known as private objects. Package definition contains the actual code for the subprograms, so, these objects are used for defining the purpose of the subprogram.
6. Which of the following is correct syntax to create a package specification in PL/SQL?
a)
CREATE package_name AS -- Package Objects END package_name; /
b)
CREATE PACKAGE package_name -- Package Objects END package_name; /
c)
CREATE PACKAGE package_name AS -- Package Objects END; /
d)
CREATE PACKAGE package_name AS -- Package Objects END package_name; /
Explanation: The correct syntax for creating a package specification is –
CREATE PACKAGE package_name AS -- Package Objects END package_name; /
The CREATE command is used along with the PACKAGE and AS keywords. The package name is decided by the user. The package objects space contains all the declaration for the objects that will be part of the package.
7. The public elements of a package can be accessed using which of the following symbol?
a) *
b) =
c) .
d) ->
View Answer
Explanation: The public elements of a package can be accessed using the dot (.) symbol. The package elements consist of the functions, procedures, and variables. These elements are declared and defined in the specification and definition part of the package respectively before they can be accessed.
8. Which of the following syntax is the correct way to access a package element?
a) package.element_name;
b) element_name.package;
c) element_name.package_name;
d) package_name.element_name;
View Answer
Explanation: The correct syntax which is used to access a package element is –
package_name.element_name;
The package name depends on the user and the element name is the name of the element which is to be accessed.
9. Which of the following is not an advantage of a PL/SQL package?
a) Modularity
b) Abstraction
c) Easier Application Design
d) No Encapsulation
View Answer
Explanation: A PL/SQL package is used to get advantages like modularity, abstraction and easier application design. A package provides the feature of encapsulation that means to combine all the things into a one single thing.
10. Which of the following package lets you use database triggers to alert an application when specific database values change?
a) DBMS_OUTPUT
b) DBMS_ALERT
c) DBMS_PIPE
d) DBMS_INPUT
View Answer
Explanation: The DBMS_ALERT package let us use the database triggers to alert an application when specific database values change. It helps in the asynchronous notification of the database events. The DBMS_ALERT uses the constants.
Sanfoundry Global Education & Learning Series – PL/SQL.
To practice all areas of PL/SQL, here is complete set of 1000+ Multiple Choice Questions and Answers.