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
View Answer

Answer: d
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
View Answer

Answer: b
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
View Answer

Answer: a
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.
advertisement
advertisement

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

Answer: b
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
View Answer

Answer: c
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()
View Answer

Answer: a
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
View Answer

Answer: a
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.
advertisement

Sanfoundry Global Education & Learning Series – PL/SQL.

advertisement

To practice all areas of PL/SQL, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.