Section 2 (Quiz)
Section 2 (Quiz)
Section 2 (Quiz)
Section 2
1. Which of the following data type conversions can be done implicitly? (Choose two.)
Mark for Review
(1) Points
NUMBER to PLS_INTEGER (*)
NUMBER to VARCHAR2 (*)
DATE to NUMBER
Incorrect. Refer to Section 2 Lesson 5.
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;
(1) Points
c=777 and d=777
c=777 and d=333444 (*)
c=333444 and d=777
Nothing. The code will result in an error.
Incorrect. Refer to Section 2 Lesson 5.
(1) Points
True (*)
False
Correct
(1) Points
PL/SQL blocks
Data types
Identifiers (*)
Literals (*)
Incorrect. Refer to Section 2 Lesson 2.
(1) Points
Composite
Reference
Scalar
LOB (*)
Incorrect. Refer to Section 2 Lesson 3.
7. Type of a variable determines the range of values the variable can have and the set of
operations that are defined for values of the type.
Mark for Review
(1) Points
True (*)
False
Correct
DECLARE
v_a NUMBER;
BEGIN
v_a := 27;
<< inner_block >>
BEGIN
v_a := 15;
END;
(1) Points
The inner block has no END; statement. (*)
Nothing is wrong, the code will execute successfully.
Variable v_a is out of scope within the inner block and therefore cannot be referenced.
The outer block has no label.
Incorrect. Refer to Section 2 Lesson 6.
9. Two variables with the same name can be declared in an outer block and an inner block.
True or False
Mark for Review
(1) Points
True (*)
False
Correct
10. Which of the following should NOT be used as the name of a variable?
Mark for Review
(1) Points
A PL/SQL reserved word.
Neither should be used. (*)
A table column name.
Incorrect. Refer to Section 2 Lesson 4.
11. Code is easier to read if you declare one identifier per line. True or False?
Mark for Review
(1) Points
True (*)
False
Incorrect. Refer to Section 2 Lesson 4.
(1) Points
* * before and after the comment
/ / before and after the comment
/* */ before and after the comment (*)
Correct
13. What good programming practice would make this code easier to follow?
DECLARE
v_myvar VARCHAR2(20);
BEGIN
DECLARE
v_myvar VARCHAR2(15);
BEGIN
...
END;
END;
(1) Points
Labeling the blocks (*)
Using a consistent naming convention for variables
Avoid using column names as identifiers
Developing a case convention for the code
Incorrect. Refer to Section 2 Lesson 7.
DECLARE
v_today DATE;
BEGIN
-- invoke the function here
Which of the following statements correctly assigns the date variable v_today to the value
returned by the format_todays_date function?
(1) Points
v_today := TO_DATE(format_todays_date, 'Month DD, YYYY'); (*)
v_today := format_todays_date ('Month DD, YYYY');
format_todays_date := v_today('Month DD, YYYY');
v_today := format_todays_date(v_today);
Incorrect. Refer to Section 2 Lesson 1.
DECLARE
test NUMBER(5);
(1) Points
Correct. (*)
Not correct.
Correct