Exception Handling in Programming Quiz

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

What are run time errors?

  • Errors related to syntax
  • Errors caused by hardware issues
  • Errors detected before code execution
  • Errors that happen during code execution (correct)

How can a programming language's exception handling functionality be used to manage runtime errors?

  • By reporting errors after program termination
  • By preventing errors from occurring
  • By ignoring errors during execution
  • By catching errors and controlling the program's response to them (correct)

What are user defined errors?

  • Errors caused by the operating system
  • Errors that occur only during compilation
  • Errors that cannot be handled by exception handling
  • Logic decisions made by the programmer to treat certain conditions as errors (correct)

What does PL/SQL use exception handling for?

<p>To ensure a program can continue operating in the presence of errors (C)</p>
Signup and view all the answers

When is the exception section added in PL/SQL?

<p>After the executable section (A)</p>
Signup and view all the answers

Which syntax handles specific exception events in PL/SQL?

<p>When clause (C)</p>
Signup and view all the answers

Which of the following is a commonly used predefined exception in PL/SQL?

<p>NO_DATA_FOUND (C)</p>
Signup and view all the answers

Which predefined exception is used to handle the situation when multiple rows are returned by a SELECT INTO statement in PL/SQL?

<p>TOO_MANY_ROWS (B)</p>
Signup and view all the answers

Which predefined exception in PL/SQL is used for handling unique constraint violations?

<p>DUP_VAL_ON_INDEX (D)</p>
Signup and view all the answers

What is the predefined exception in PL/SQL used for handling unique constraint violations?

<p>DUP_VAL_ON_INDEX (A)</p>
Signup and view all the answers

When is DUP_VAL_ON_INDEX exception used in PL/SQL?

<p>When trying to insert a duplicate value into a column constrained by a unique index (A)</p>
Signup and view all the answers

What type of error does DUP_VAL_ON_INDEX handle in PL/SQL?

<p>Unique constraint violations (D)</p>
Signup and view all the answers

What is the exception raised when a SELECT INTO statement retrieves zero rows in PL/SQL?

<p>NO_DATA_FOUND (C)</p>
Signup and view all the answers

Which exception is raised when a SELECT INTO statement retrieves more than one row in PL/SQL?

<p>TOO_MANY_ROWS (D)</p>
Signup and view all the answers

What is executed first in a code block?

<p>Initialization code (D)</p>
Signup and view all the answers

How many exceptions can happen for an iteration/row data?

<p>Only one if it is met (C)</p>
Signup and view all the answers

Does exception handler code block only deal with errors?

<p>No (A)</p>
Signup and view all the answers

What is the purpose of using the OTHERS exception in PL/SQL when there is more than one exception handler?

<p>To handle any unanticipated exceptions not explicitly handled by other exception handlers (C)</p>
Signup and view all the answers

Why does the OTHERS exception not include hard-coded error messages in PL/SQL?

<p>To allow flexibility in handling different types of exceptions without the need to modify the code (C)</p>
Signup and view all the answers

What is used to identify the error message associated with the OTHERS exception in PL/SQL?

<p>SQLERRM (D)</p>
Signup and view all the answers

What must be controlled by the programmer in exception handling?

<p>How the program ends (B)</p>
Signup and view all the answers

How will the program end in a controlled manner after the ZERO_DIVIDE exception handler block is executed?

<p>The program will continue executing normally (D)</p>
Signup and view all the answers

How will the program end in an uncontrolled manner after the ZERO_DIVIDE exception handler block is executed?

<p>The program will terminate abruptly (B)</p>
Signup and view all the answers

Which exception handler is executed when there are no employees for the given department id?

<p>NO_DATA_FOUND (B)</p>
Signup and view all the answers

Which exception handler is executed when the department id is not a valid number?

<p>INVALID_NUMBER (B)</p>
Signup and view all the answers

What is the nature of Oracle non-predefined exceptions?

<p>They occur automatically for specific events (D)</p>
Signup and view all the answers

What are Oracle non-predefined exceptions not associated with?

<p>Exception name (D)</p>
Signup and view all the answers

How do you handle Oracle non-predefined exceptions in PL/SQL?

<p>Use the 'OTHERS' exception or explicitly name the exception (C)</p>
Signup and view all the answers

What is the purpose of the PRAGMA EXECPTION_INIT in PL/SQL?

<p>To associate an exception with an error code (D)</p>
Signup and view all the answers

What type of directive is PRAGMA in PL/SQL?

<p>Compiler directive (C)</p>
Signup and view all the answers

What are the two parameters required for the PRAGMA EXECPTION_INIT directive?

<p>Exception name and error code (C)</p>
Signup and view all the answers

In PL/SQL, what is the number for the error code when an exception variable must be created (always negative)?

<p>-20000 (D)</p>
Signup and view all the answers

In PL/SQL, when must the exception variable be created?

<p>Before it is called (D)</p>
Signup and view all the answers

In PL/SQL, what is the purpose of the error code being always negative?

<p>To differentiate between predefined and non-predefined exceptions (A)</p>
Signup and view all the answers

What is the purpose of creating a variable of type EXCEPTION in PL/SQL?

<p>To define a specific type of error that can be raised and handled (C)</p>
Signup and view all the answers

What is the purpose of the RAISE statement in PL/SQL?

<p>To manually cause a runtime error to occur using a specified exception variable (B)</p>
Signup and view all the answers

What happens if an unanticipated error occurs within a PL/SQL block?

<p>The exception handler for OTHERS will catch the error and print out an error message (A)</p>
Signup and view all the answers

What are the two steps involved in using RAISE in PL/SQL for exception handling?

<p>Create a variable of type EXCEPTION for each handler needed, RAISE the error using this variable (B)</p>
Signup and view all the answers

What is the purpose of creating a variable of type EXCEPTION in PL/SQL?

<p>To use it for raising specific exceptions (B)</p>
Signup and view all the answers

What is the example JSON format used for in PL/SQL?

<p>To demonstrate exception handling (C)</p>
Signup and view all the answers

What range of error codes is provided by Oracle for user-defined errors in PL/SQL?

<p>-20000 to -20999 (B)</p>
Signup and view all the answers

Which exception handler will catch errors raised using the RAISE_APPLICATION_ERROR procedure in PL/SQL?

<p>OTHERS (C)</p>
Signup and view all the answers

What happens if an error occurs within an anonymous block in PL/SQL that uses RAISE_APPLICATION_ERROR?

<p>The error is caught and printed by the exception handler (A)</p>
Signup and view all the answers

What does SQLCODE return inside the exception block in PL/SQL?

<p>The numeric value of the error code associated with an exception (A)</p>
Signup and view all the answers

What does SQLERRM return inside the exception block in PL/SQL?

<p>The message associated with an error code (C)</p>
Signup and view all the answers

What method is used to display a message to the screen for the OTHERS exception handler in PL/SQL?

<p>DBMS_OUTPUT.PUT_LINE(SQLERRM) (B)</p>
Signup and view all the answers

Why can't SQLERRM be used directly in an INSERT statement in PL/SQL?

<p>Because of a size issue that the INSERT is unable to resolve (A)</p>
Signup and view all the answers

Flashcards are hidden until you start studying

More Like This

PL/SQL and Database Management Quiz
5 questions

PL/SQL and Database Management Quiz

SustainableLepidolite4776 avatar
SustainableLepidolite4776
PL/SQL Composite Data Types Quiz
10 questions
PL/SQL: SQL, DML, DDL Statements and Cursors
29 questions
PL/SQL: SQL Statements and Cursor Attributes
39 questions
Use Quizgecko on...
Browser
Browser