100% found this document useful (1 vote)
4K views5 pages

Section 2 Quiz

This document contains a 15 question quiz on PL/SQL concepts. The questions cover topics like: - Lexical units and what statements are true about them - What is displayed when a specific code block is executed - Whether a variable declaration is correct - Valid PL/SQL operators - Examples of good programming practices - The advantages of declaring a variable as another object's type - Character data types The questions require selecting answers, identifying correct code, and explaining errors.

Uploaded by

daemon29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
4K views5 pages

Section 2 Quiz

This document contains a 15 question quiz on PL/SQL concepts. The questions cover topics like: - Lexical units and what statements are true about them - What is displayed when a specific code block is executed - Whether a variable declaration is correct - Valid PL/SQL operators - Examples of good programming practices - The advantages of declaring a variable as another object's type - Character data types The questions require selecting answers, identifying correct code, and explaining errors.

Uploaded by

daemon29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Section 2 Quiz

(Answer all questions in this section)

1. Which statements about lexical units are true? (Choose two.) Mark for Review
(1) Points

(Choose all correct answers)

They are sequences of characters including letters, digits, tabs, returns and
symbols (*)
They are optional but can make a PL/SQL block execute faster
They are the building blocks of every PL/SQL program (*)
They are named objects stored in the database

Correct

2. What is a lexical unit? Mark for Review


(1) Points

A data type for a column


A building block of a PL/SQL block (*)
A type of variable

Correct

3. What will be displayed when the following code is executed? Mark for Review
DECLARE (1) Points
x VARCHAR2(6) := 'Chang';
BEGIN
DECLARE
x VARCHAR2(12) := 'Susan';
BEGIN
x := x || x;
END;
DBMS_OUTPUT.PUT_LINE(x);
END;

Susan
Chang (*)
The code will fail with an error
ChangChang
SusanChang

Correct
4. A variable defined in an outer block is global to the outer block and local to the inner Mark for Review
block. True or False?
(1) Points

True
False (*)

Correct

5. Is the following variable declaration correct or not? Mark for Review


DECLARE (1) Points
maxsalary NUMBER(7) = 5000;

Correct.
Not correct. (*)

Incorrect. Refer to Section 2 Lesson 1.


6. Examine the
following Mark for Review
variable (1) Points
declarations:

DECLARE
v_number
NUMBER :=
10;
v_result
NUMBER;

Which of the
following
correctly
assigns the
value 50 to
V_RESULT?

All of these are correct (*)


v_result := 100 / 2;
v_result := ROUND(49.77);
v_result := v_number * 5;

Incorrect. Refer to Section 2 Lesson 1.

7. The implicit data type conversion at Point A may not work correctly. Why not? Mark for Review
DECLARE (1) Points
v_mydate DATE;
BEGIN
V_MYDATE := '29-Feb-2004'; -- Point A
END;

V_MYDATE has been entered in uppercase


Oracle cannot implicitly convert a character string to a date, even if the
string contains a valid date value (*)
There are only 28 days in February
If the database language is not English, 'Feb' has no meaning.

Incorrect. Refer to Section 2 Lesson 5.

8. Which of the following are valid PL/SQL operators? (Choose three.) Mark for Review
(1) Points

(Choose all correct answers)

Exponential (*)
Arithmetic (*)
Concatenation (*)
Exception

Correct

9. Examine the following block. What should be coded at Line A? Mark for Review
DECLARE
v_char VARCHAR2(8) := '24-Sep-2007'; (1) Points
v_date DATE;
BEGIN
v_date := ....... Line A
END;

v_date := TO_DATE(v_char,'dd-Mon-YYYY'); (*)


v_date := v_char;
v_date := FROM_CHAR(v_char,'dd-Mon-YYYY');

Correct

10. Which of the following is a composite data type? Mark for Review
(1) Points

DATE
VARCHAR2
CLOB
RECORD (*)

Correct
11. Which Mark for Review
statement
most (1) Points
closely
describes
"data
type"?

It allows different kinds of data to be stored in a single variable.


It is the value of a variable.
It specifies a storage format, constraints, and a valid range of values for a
variable. (*)
It is used to test if errors have occurred.

Correct

12. Which of the following makes PL/SQL code easier to read and maintain? Mark for Review
(1) Points

Type everything in lowercase.


Place multiple statements on the same line.
Use suitable comments in the code. (*)

Incorrect. Refer to Section 2 Lesson 7.

13. Which of the following are examples of good programming practice? (Choose Mark for Review
three.)
(1) Points

(Choose all correct answers)

Develop naming conventions for identifiers and other objects. (*)


Indent code so that it can be read more easily. (*)
Document code with comments. (*)
Use implicit data type conversions.
Use table column names as the names of variables.

Incorrect. Refer to Section 2 Lesson 7.

14. You need to declare a variable to hold a value which has been read from the Mark for Review
SALARY column of the EMPLOYEES table. Which of the following is an
advantage of declaring the variable as: employees.salary%TYPE ? (1) Points
If the SALARY column is ALTERed later, the PL/SQL code need not be
changed. (*)
It is shorter than coding NUMBER(8,2)
It executes much faster than using NUMBER(8,2)
It allows the software to perform implicit data type conversions.

Correct

15. Which of the following is NOT a character data type? Mark for Review
(1) Points

LONG
BOOLEAN (*)
CHAR
VARCHAR2

Correct

You might also like