Exception Handling in Programming Quiz
47 Questions
3 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

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</p> Signup and view all the answers

    When is the exception section added in PL/SQL?

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

    Which syntax handles specific exception events in PL/SQL?

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

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

    <p>NO_DATA_FOUND</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</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</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</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</p> Signup and view all the answers

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

    <p>Unique constraint violations</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</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</p> Signup and view all the answers

    What is executed first in a code block?

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

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

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

    Does exception handler code block only deal with errors?

    <p>No</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</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</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</p> Signup and view all the answers

    What must be controlled by the programmer in exception handling?

    <p>How the program ends</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</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</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</p> Signup and view all the answers

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

    <p>INVALID_NUMBER</p> Signup and view all the answers

    What is the nature of Oracle non-predefined exceptions?

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

    What are Oracle non-predefined exceptions not associated with?

    <p>Exception name</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</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</p> Signup and view all the answers

    What type of directive is PRAGMA in PL/SQL?

    <p>Compiler directive</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</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</p> Signup and view all the answers

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

    <p>Before it is called</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</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</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</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</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</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</p> Signup and view all the answers

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

    <p>To demonstrate exception handling</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</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</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</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</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</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)</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</p> Signup and view all the answers

    More Like This

    PL/SQL and Database Management Quiz
    5 questions

    PL/SQL and Database Management Quiz

    SustainableLepidolite4776 avatar
    SustainableLepidolite4776
    PL/SQL Quiz
    5 questions

    PL/SQL Quiz

    ThriftyErudition avatar
    ThriftyErudition
    PL/SQL Composite Data Types Quiz
    10 questions
    Use Quizgecko on...
    Browser
    Browser