Section 2 (Quiz)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

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.

2. What is the output when the following program is executed?

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;

Mark for Review

(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.

3. What will happen when the following code is executed?


DECLARE v_new_date DATE;
BEGIN
v_new_date := 'Today';
DBMS_OUTPUT.PUT_LINE(v_new_date);
END;
Mark for Review
(1) Points
The block will execute and display the word "Today".
The block will execute and display today's date.
The block will fail because the character value "Today" cannot be implicitly converted to a
date. (*)
Incorrect. Refer to Section 2 Lesson 5.

4. The name of a variable is an example of an identifier. True or False?


Mark for Review

(1) Points
True (*)
False
Correct

5. Which of the following are lexical units? (Choose two.)


Mark for Review

(1) Points
PL/SQL blocks
Data types
Identifiers (*)
Literals (*)
Incorrect. Refer to Section 2 Lesson 2.

6. A movie is an example of which category of data type?


Mark for Review

(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

8. What is wrong with this code?

DECLARE
v_a NUMBER;
BEGIN
v_a := 27;
<< inner_block >>
BEGIN
v_a := 15;
END;

Mark for Review

(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.

12. What symbol is used to comment a series of lines?


Mark for Review

(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;

Mark for Review

(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.

14. A function called FORMAT_TODAYS_DATE accepts no parameters and returns today's


date in the format: Month DD, YYYY

The following anonymous block invokes the function:

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?

Mark for Review

(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.

15. Is the following variable declaration correct or not?

DECLARE
test NUMBER(5);

Mark for Review

(1) Points
Correct. (*)
Not correct.
Correct

You might also like