Oracle Database Programming MCQs with Answers
Practice important Oracle Database Programming MCQs with answers and explanations.
Chapter: 12
Q181:
In nested exception handling, which block's exception handler takes precedence if both inner and outer blocks have exception handlers?
A. Inner block's exception handler
B. Outer block's exception handler
C. Both handle the exception equally
D. Neither handle the exception properly
Correct Answer:
A
Chapter: 12
Q182:
Which component is NOT part of a built-in exception in PL/SQL?
A. Exception Name
B. Exception Unique Number
C. Exception Description
D. Exception Variable
Correct Answer:
D
Chapter: 12
Q183:
What will be the output of the program if an `INSERT` statement violates a unique key constraint?
A. Record not matched
B. Unique Key Violated
C. ORA-01422: exact fetch returns more than requested number of rows
D. Invalid Number
Correct Answer:
B
Chapter: 12
Q184:
When handling exceptions in PL/SQL, which section contains the exception handling statements?
A. Declare Section
B. Begin Section
C. Exception Section
D. End Section
Correct Answer:
C
Chapter: 12
Q185:
In PL/SQL, what is the result of a `DUP_VAL_ON_INDEX` exception?
A. The record already exists
B. The SQL error code
C. The error message associated with the exception
D. The record was not found
Correct Answer:
A
Chapter: 12
Q186:
Which PL/SQL block structure is used to handle runtime errors?
A. Declare-Exception
B. Begin-Exception
C. Begin-Exception-End
D. Declare-Begin-End
Correct Answer:
C
Chapter: 12
Q187:
What type of exceptions are raised implicitly by the PL/SQL runtime system?
A. User-defined exceptions
B. Internal exceptions
C. Predefined exceptions
D. All of the above
Correct Answer:
B
Chapter: 12
Q188:
What does the `RAISE` statement do in PL/SQL?
A. Declares an exception
B. Triggers an exception defined by the user
C. Handles an exception
D. Ends the program execution
Correct Answer:
B
Chapter: 12
Q189:
What is the purpose of the `dbms_output.put_line` statement in exception handling examples?
A. To terminate the program
B. To display error messages
C. To raise exceptions
D. To execute SQL statements
Correct Answer:
B
Chapter: 12
Q190:
When multiple rows are returned by a `SELECT` statement without using a cursor, what exception is raised?
A. ORA-01422: exact fetch returns more than requested number of rows
B. Invalid Number
C. Duplicate Value
D. No Data Found
Correct Answer:
A
Chapter: 12
Q191:
What should be done if the `NO_DATA_FOUND` exception occurs during a `SELECT` operation?
A. Display a custom message
B. Ignore the exception
C. Terminate the program
D. Retry the operation
Correct Answer:
A
Chapter: 13
Q192:
What is a User Defined Exception in PL/SQL?
A. A default exception automatically provided by PL/SQL
B. A built-in exception predefined by the system
C. A custom exception defined by the user
D. A standard exception for all applications
Correct Answer:
C
Chapter: 13
Q193:
Where must a User Defined Exception be declared in a PL/SQL block?
A. Begin Section
B. Declare Section
C. Exception Section
D. End Section
Correct Answer:
B
Chapter: 13
Q194:
What is the syntax to declare a User Defined Exception?
A. DECLARE exception_name EXCEPTION; BEGIN statements; EXCEPTION WHEN exception_name THEN action; END;
B. DECLARE exception_name EXCEPTION; BEGIN statements; EXCEPTION WHEN exception_name THEN action; END;
C. DECLARE exception_name EXCEPTION; BEGIN statements; EXCEPTION WHEN exception_name THEN action; END;
D. DECLARE exception_name EXCEPTION; BEGIN statements; EXCEPTION WHEN exception_name THEN action; END;
Correct Answer:
B
Chapter: 13
Q195:
Which statement is used to raise a User Defined Exception?
A. THEN
B. Raise
C. EXCEPTION
D. IF
Correct Answer:
B
Chapter: 13
Q196:
In which section of the PL/SQL block are User Defined Exceptions handled?
A. Declare Section
B. Begin Section
C. Exception Section
D. End Section
Correct Answer:
C
Chapter: 13
Q197:
What is the output if the `salary` is less than `5000` in the given PL/SQL block?
A. Valid Salary
B. InValid Salary
C. No Data Found
D. Unique Key Violated
Correct Answer:
B
Chapter: 13
Q198:
What happens if an exception is raised in an inner block but not handled there?
A. The program terminates immediately
B. The outer block handles the exception
C. The exception is ignored
D. The program continues without handling the exception
Correct Answer:
B
Chapter: 13
Q199:
What will be displayed if a salary is less than the minimum salary in the `Implementing User Defined Exception –II` example?
A. Salary is less than the defined minimum
B. Valid Salary
C. No Data Found
D. Invalid Operation
Correct Answer:
A
Chapter: 13
Q200:
In the provided `Implementing User Defined Exception –III` example, where is the `past_due` exception declared?
A. Only in the inner block
B. Only in the outer block
C. In both inner and outer blocks
D. Nowhere, it’s not declared properly
Correct Answer:
B