SECTION 2
1. A
Scalar Mark for Review
data (1) Points
type
holds
a(n)
____
value.
Single (*)
Multi
Large
image
Correct
2. _____ are meant to store large amounts of data.
Mark for Review
(1) Points
VARCHAR2s
LOBs (*)
Scalar data types
Variables
Incorrect. Refer to Section 2 Lesson 3.
3. Which of the following declarations is invalid?
Mark for Review
(1) Points
v_start_date DATE := sysdate+1;
v_count PLS_INTEGER:=0;
v_pages CONSTANT NUMBER; (*)
college_name VARCHAR2(20):='Harvard';
Incorrect. Refer to Section 2 Lesson 4.
4. If you use the %TYPE attribute, you can avoid hard-coding the column name. True
or False? Mark for Review
(1) Points
True
False (*)
Correct
5. What will be displayed when the following block is executed?
Mark for Review
<< outer >> (1) Points
DECLARE
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;
World
HelloWorld
The code will fail since the inner variable is not within the scope of the outer
block. (*)
Hello World
Incorrect. Refer to Section 2 Lesson 6.
6. If an
outer Mark for Review
block is (1) Points
labeled,
the
inner
block
must
be
labeled
also.
True or
False?
True
False (*)
Incorrect. Refer to Section 2 Lesson 6.
7. Assignment statements can continue over several lines in PL/SQL. True or False?
Mark for Review
(1) Points
True (*)
False
Correct
8. Constants must be initialized. True or False?
Mark for Review
(1) Points
True (*)
False
Correct
9. What good programming practice would make this code easier to follow?
Mark for Review
DECLARE (1) Points
v_myvar VARCHAR2(20);
BEGIN
DECLARE
v_myvar VARCHAR2(15);
BEGIN
...
END;
END;
Developing a case convention for the code
Avoid using column names as identifiers
Using a consistent naming convention for variables
Labeling the blocks (*)
Incorrect. Refer to Section 2 Lesson 7.
10. Which of the following makes PL/SQL code easier to read and maintain?
Mark for Review
(1) Points
Type everything in lowercase.
Use suitable comments in the code. (*)
Place multiple statements on the same line.
Correct
11. Which of
the Mark for Review
following (1) Points
is
correct?
V_FAMILY_NAME = SMITH;
v_family_name := 'SMITH'; (*)
v_family_name := SMITH;
v_family_name = SMITH;
Correct
12. What will happen when the following code is executed?
DECLARE v_new_date DATE; Mark for Review
BEGIN (1) Points
v_new_date := 'Today';
DBMS_OUTPUT.PUT_LINE(v_new_date);
END;
The block will fail because the character value "Today" cannot be implicitly
converted to a date. (*)
The block will execute and display today's date.
The block will execute and display the word "Today".
Correct
13. PL/SQL statements must be written on a single line.
Mark for Review
(1) Points
True
False (*)
Correct
14. Delimiters are _____ that have special meaning to the Oracle database.
Mark for Review
(1) Points
variables
identifiers
symbols (*)
Incorrect. Refer to Section 2 Lesson 2.
15. Which of the following symbols can be used to enclose a comment in PL/SQL?
Mark for Review
(1) Points
*/ / *
/* */ (*)
??
:: ::
Correct
1. What good
programming Mark for Review
practice would (1) Points
make this code
easier to
follow?
DECLARE
v_myvar
VARCHAR2(20);
BEGIN
DECLARE
v_myvar
VARCHAR2(15);
BEGIN
...
END;
END;
Using a consistent naming convention for variables
Labeling the blocks (*)
Avoid using column names as identifiers
Developing a case convention for the code
Incorrect. Refer to Section 2 Lesson 7.
2. Comments change how a PL/SQL program executes, so an unsuitable
comment can cause the program to fail. True or False? Mark for Review
(1) Points
True
False (*)
Correct
3. Which of the following is a composite data type?
Mark for Review
(1) Points
CLOB
VARCHAR2
RECORD (*)
DATE
Correct
4. A datatype specifies and restricts the possible data values that can be
assigned to a variable. True or False? Mark for Review
(1) Points
True (*)
False
Correct
5. Which of the following is NOT a good guideline for declaring variables?
Mark for Review
(1) Points
Use column names as identifiers (*)
Use NOT NULL when the variable must have a value
Declare one identifier per line
Correct
6. A
variable Mark for Review
must (1) Points
have a
value if
NOT
NULL is
specified.
True or
False?
True (*)
False
Correct
7. The LENGTH and ROUND functions can be used in PL/SQL statements. True or
False? Mark for Review
(1) Points
True (*)
False
Correct
8. If today's date is 14th June 2007, which statement will correctly convert today's
date to the value: June 14, 2007 ? Mark for Review
(1) Points
TO_DATE(sysdate,'Month DD, YYYY')
TO_CHAR(sysdate)
TO_DATE(sysdate)
TO_CHAR(sysdate, 'Month DD, YYYY') (*)
Incorrect. Refer to Section 2 Lesson 5.
9. What is the output when the following program is executed?
Mark for Review
set serveroutput on (1) Points
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;
c=777 and d=777
c=777 and d=333444 (*)
c=333444 and d=777
Nothing. The code will result in an error.
Correct
10. Is the following variable declaration correct or not?
Mark for Review
DECLARE (1) Points
test NUMBER(5);
Correct. (*)
Not correct.
Correct
11. Which of
the Mark for Review
following (1) Points
are
required
when
declaring
a
variable?
(Choose
two.)
(Choose all correct answers)
CONSTANT
Data type (*)
Identifier name (*)
NOT NULL
Correct
12. The name of a variable is an example of an identifier. True or False?
Mark for Review
(1) Points
True (*)
False
Correct
13. Which of the following are valid identifiers? (Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
yesterday (*)
yesterday's date
number_of_students_in_the_class
#students
v$testresult (*)
Correct
14. Examine the following code. What is the scope of variable v_myvar?
DECLARE Mark for Review
v_myvar NUMBER; (1) Points
BEGIN
v_myvar := 6;
DECLARE
v_hervar NUMBER;
BEGIN
v_hervar := 4;
END;
END;
Neither block
Only the outer block
Only the inner block
Both the inner and the outer block (*)
Correct
15. For the anonymous block below, what is the correct reference to the father's
date of birth in the inner block? Mark for Review
(1) Points
<< outer>>
DECLARE
v_father_name VARCHAR2(20):='Patrick';
v_date_of_birth DATE:='20-Apr-1972';
BEGIN
DECLARE
v_child_name VARCHAR2(20):='Mike';
v_date_of_birth DATE:='12-Dec-2002';
...
outer.v_date_of_birth (*)
<< outer.v_date_of_birth >>
<< outer>>v_date_of_birth
v_date_of_birth.outer
Correct