# PL/SQL Questions and Answers – PL/SQL Constants and Literals

This set of PL/SQL Multiple Choice Questions & Answers (MCQs) focuses on “PL/SQL Constants and Literals”.

1. How many types of literals are present in PL/SQL?
a) 2
b) 3
c) 4
d) 5

Explanation: There are 5 types of literals present in PL/SQL. They include – Numeric Literals, Character Literals, String Literals, Boolean Literals, Date and Time Literals.

2. In PL/SQL we can change the value of a constant later on in the program.
a) True
b) False

Explanation: A PL/SQL constant hold a value that does not change during the whole execution of the program, the value which must be assigned to a constant when it is declared. You can’t give it later.

3. A literal is an explicit numeric, character, string, or boolean value not represented by an identifier.
a) True
b) False

Explanation: In PL/SQL, a literal is equivalent to a constant. They are case-sensitive. A literal is a value that is not represented by an identifier; it is simply a value. For example, TRUE, 100, NULL, ‘sanfoundry’ are all literals.

4. In PL/SQL, the string literals are always enclosed within which symbol?
a) ()
b) ‘’
c) “”
d) {}

Explanation: In PL/SQL, the string literals are always enclosed within a pair of single quotes (‘’). For example – ‘Sanfoundry’ or ’28-December-2020’.

5. In PL/SQL, a numeric literal can hold up-to how many digits?
a) 12
b) 24
c) 38
d) 56

Explanation: In PL/SQL, Numeric literals can be up to 38 digits. These literals can be either positive or negative numbers. Also, it can be integer or float. For example – 031, -25, 4.679.

6. Which of the following function is used to convert a literal into a date?
a) TO_DATE()
b) DATE()
c) CONVERT_DATE()
d) INTO_DATE()

Explanation: In PL/SQL, when dealing with date values, we will have to use the TO_DATE() function to convert a literal to a date. For example –

`SELECT TO_DATE (‘2020/12/28’, ‘yyyy/mm/dd’) FROM TABLE_NAME;`

7. In PL/SQL, we can also use digits in place of characters for character literals.
a) True
b) False

Explanation: In PL/SQL, Character literals are string literals consisting of only single characters. They are enclosed within single quotes (‘’) and we can use digits and symbols in place of characters as long as the digit and the symbol is individual.

Sanfoundry Global Education & Learning Series – PL/SQL.