SlideShare a Scribd company logo
Exception Handler
Questions # 1 Define Exception, exception handler, raising an exception, disabling an exception, continuation and built in exception.
Answer Exceptions are errors detected by hardware, such as disk read errors and unusual conditions such as end files. These are also unusual events , erroneous or not, that is detectable either by hardware or software and that may require special processing.
Answer Exception Handler is a code unit that monitors the special processing that may be required by the detection of an exception or also called exception handling. Raising an Exception An object raises an exception when it has trapped an error. An object raises an exception by sending itself the "raiseException" message, passing an error number as a parameter.
Answer Continuation is the question of control continuation after handler execution for an exception handler executes either control can transfer to somewhere in the program outside of the hadler code, or program execution can simply terminate. Built in Exception is an exception that is constructed as part of the language and is not detachable.
Question # 2 What are the design issues for an exception handling?
Answer 1. Form – a choice between having handlers that are complete programs units or handlers that are code segments. They may be embedded in the units that caused the exception they are to handle or they may be embedded in a different unit, such as the unit that called the one in which the exception is raised.
Answer 2. How an exception occurrence is bound to an exception handler – This occurs in two different levels, On the unit level, there is the question of how the same exception being raised at different points in a unit can be bound to different handlers within the unit. It should be possible to bind the exception that can be raised by particular statements to particular handlers, even though the same exception can be raised by many different statements. At the higher level, the binding question arises when there is no exception handler local to the unit in which the exception is raised. If exceptions are propagated, a single handler might handle the same exceptions raised in several program units, which may require the handler to be more general than one would prefer.
Answer 3. Whether the binding of exceptions to handlers is static or dynamic , that is , whether binding depends on the syntactic layout of the program or on its execution sequence. As it is in other language constructs, static binding of exceptions is easier to understand and implement than dynamic binding.
Answer 4. If users are allowed to define exceptions, how are there exceptions specified? The usual answer is to require that they be declared in the specifications parts of the program units in which they can be raised. 5. Whether built in exceptions can be raised explicitly by the user program. This can be convenient if there are software – detectable situations in which the user would like to use a built- handler.
Answer 6. Whether hardware-detectable errors should be treated as exceptions that could be handled by user program. It not, all exceptions obviously are software-detectable. A related question is whether there should be any built in exceptions. 7. Whether exception, either built in or user-defined, can be temporarily or permanently disabled.
Question # 3 What does it mean for an exception to be bound to an exception handler?
Answer If the block or unit in which an exception is raised does not  have a handler for that exception, the exception is propagated  elsewhere to be handled – Procedures - propagate it to the caller – Blocks - propagate it to the scope in which it appears – Package body - propagate it to the declaration part of the unit  that declared the package (if it is a library unit, the program is  terminated)
Answer –  Task - no propagation; if it haandler, execute it; in either case, mark it "completed --- Sa JAVA  Binding an exception to a handler is simpler in Java than it is  in C++ – An exception is bound to the first handler with a parameter is  the same class as the thrown object or an ancestor of it • An exception can be handled and rethrown by including a  throw in the handler (a handler could also throw a different  exception)
Question # 4 What is the parent class of most Java user-defined exception classes?
Answer Throwable class. Based on the book, All Java exceptions are objects of classes that are descendants of the Throwable class
Question # 5 How can an exception handler be written in Java so that it handles any exceptions?
Answer To ensure that exceptions can be thrown in a try clause are always handled in a method, a special handler can be written that matches all exceptions that are derived from Exception simply by defining the handler with an Exception type parameter as in catch (Exception genericObject) { … }
Question # 6 What is the difference between a C++ throw specifications and a Java throws clause?
Answer 1. A C++ program can throw any type defined in the program or by the system. In Java, only objects that are instances of Throwable or some class that descends from it can be thrown. 2. A C++ program unit that does not include a throws clause can throw any exception, which tells the reader nothing. A Java method that does not include throws clause cannot throw any checked exceptions that it does not handle. Therefore, the reader of a Java method knows from its header what exceptions it could throw but does not handle.
Answer 3. The addition of the finally clause is great convenience in certain situations. It allows cleanup kinds of actions to take place regardless of how a compound statement terminated. 4. The Java run-time system implicitly throws a variety of exceptions, such as for array indices out of range and null reference variable accesses, which can be handled by any user program. A C++ program can handle only those exceptions that it explicitly throws.
Question # 7 What is the difference between checked and unchecked exceptions in Java?
Answer Checked exceptions are carried out or executed whenever there is an error in the syntax and programming-side while unchecked exceptions hold the errors that might occur during user or data interaction.
Question # 8 Can you disable a Java exception?
Answer There are exceptions in Java that are automatically invoked when a data-specific error occurs. These exceptions are also called checked exceptions. They cannot be disabled as they are built-in with the Java API. But if you are using an unchecked exception, you may disable it intentionally or unintentionally by using a break; statement just before a line that might throw an exception.
Question # 9 What is the purpose of the Java finally clause?
Answer Purpose: To specify code that is to be executed, regardless of  what happens in the try construct
Kristine Ancheta Stephanie Rosanna Blanza Desney Ann Caracot Roshe Nikhka de Guzman Rhys Anton Gabion Erick Lester Sumugat Carlo Mar

More Related Content

PPTX
Exception handling
PDF
Exception handling
PPS
Exception handling in c programming
PPT
Week7 exception handling
PPT
Exception handling in c++ by manoj vasava
PPTX
What is Exception Handling?
PDF
Exception Handling
PPT
Exception handling
Exception handling
Exception handling
Exception handling in c programming
Week7 exception handling
Exception handling in c++ by manoj vasava
What is Exception Handling?
Exception Handling
Exception handling

What's hot (20)

PPTX
Exception handling chapter15
PDF
14 exception handling
PPSX
Exception Handling
PPTX
Exception Handling in C++
PPT
Understanding Exception Handling in .Net
PPTX
C++ ala
PDF
Exception handling
PPT
Exception Handling Java
PDF
javaexceptions
PPT
Exceptions in c++
PDF
Best Practices in Exception Handling
PPT
Exception handling
PPTX
Presentation1
PPT
C# Exceptions Handling
PPTX
Exception handling in c++
ODP
Exception Handling In Java
PPTX
Java exception handling
PPTX
Chap2 exception handling
PPTX
Exception handling in java
PPTX
Exception handling in asp.net
Exception handling chapter15
14 exception handling
Exception Handling
Exception Handling in C++
Understanding Exception Handling in .Net
C++ ala
Exception handling
Exception Handling Java
javaexceptions
Exceptions in c++
Best Practices in Exception Handling
Exception handling
Presentation1
C# Exceptions Handling
Exception handling in c++
Exception Handling In Java
Java exception handling
Chap2 exception handling
Exception handling in java
Exception handling in asp.net
Ad

Viewers also liked (7)

PPTX
exception handling in cpp
PDF
Exception Handling in the C++ Constructor
PPT
Exception Handling1
PPT
Handling Exceptions In C & C++[Part A]
PPT
Exception handling and templates
PPTX
Scripting languages
PPS
Java Exception handling
exception handling in cpp
Exception Handling in the C++ Constructor
Exception Handling1
Handling Exceptions In C & C++[Part A]
Exception handling and templates
Scripting languages
Java Exception handling
Ad

Similar to Exception handler (20)

PPTX
Java Exception Handling and examples about it
DOCX
Java Exception handling
PPTX
Java programming-Event Handling
PDF
Exception handling
PDF
Exception handling
PPTX
Exception handling in Java
PPTX
Chapter 5
PDF
Bt0074 oops with java2
DOC
MC0078 SMU 2013 Fall session
PPTX
4185_Exception-Handling-in-Java object oriented programming
PDF
Java Faqs useful for freshers and experienced
PPTX
Exception-Handling-in-Java-A-Comprehensive-Guide (1).pptx
PDF
Top 371 java fa qs useful for freshers and experienced
PPTX
Exception handling in java
PPTX
Week 4 - 5 Debugging Code and Analyzing Logic Errors.pptx
PPT
Excetion handling Software Engineering Units
PPSX
Java Exceptions Handling
PPSX
Java Exceptions
PPT
Java exception
PPTX
Module 4.pptxModule 4.pptxModuModule 4.pptxModule 4.pptxle 4.pptx
Java Exception Handling and examples about it
Java Exception handling
Java programming-Event Handling
Exception handling
Exception handling
Exception handling in Java
Chapter 5
Bt0074 oops with java2
MC0078 SMU 2013 Fall session
4185_Exception-Handling-in-Java object oriented programming
Java Faqs useful for freshers and experienced
Exception-Handling-in-Java-A-Comprehensive-Guide (1).pptx
Top 371 java fa qs useful for freshers and experienced
Exception handling in java
Week 4 - 5 Debugging Code and Analyzing Logic Errors.pptx
Excetion handling Software Engineering Units
Java Exceptions Handling
Java Exceptions
Java exception
Module 4.pptxModule 4.pptxModuModule 4.pptxModule 4.pptxle 4.pptx

Recently uploaded (20)

PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
01-Introduction-to-Information-Management.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
master seminar digital applications in india
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Pre independence Education in Inndia.pdf
PPTX
Cell Structure & Organelles in detailed.
Pharmacology of Heart Failure /Pharmacotherapy of CHF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Computing-Curriculum for Schools in Ghana
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
01-Introduction-to-Information-Management.pdf
Insiders guide to clinical Medicine.pdf
Complications of Minimal Access Surgery at WLH
VCE English Exam - Section C Student Revision Booklet
102 student loan defaulters named and shamed – Is someone you know on the list?
master seminar digital applications in india
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Final Presentation General Medicine 03-08-2024.pptx
Renaissance Architecture: A Journey from Faith to Humanism
Anesthesia in Laparoscopic Surgery in India
Supply Chain Operations Speaking Notes -ICLT Program
PPH.pptx obstetrics and gynecology in nursing
O5-L3 Freight Transport Ops (International) V1.pdf
GDM (1) (1).pptx small presentation for students
Pre independence Education in Inndia.pdf
Cell Structure & Organelles in detailed.

Exception handler

  • 2. Questions # 1 Define Exception, exception handler, raising an exception, disabling an exception, continuation and built in exception.
  • 3. Answer Exceptions are errors detected by hardware, such as disk read errors and unusual conditions such as end files. These are also unusual events , erroneous or not, that is detectable either by hardware or software and that may require special processing.
  • 4. Answer Exception Handler is a code unit that monitors the special processing that may be required by the detection of an exception or also called exception handling. Raising an Exception An object raises an exception when it has trapped an error. An object raises an exception by sending itself the "raiseException" message, passing an error number as a parameter.
  • 5. Answer Continuation is the question of control continuation after handler execution for an exception handler executes either control can transfer to somewhere in the program outside of the hadler code, or program execution can simply terminate. Built in Exception is an exception that is constructed as part of the language and is not detachable.
  • 6. Question # 2 What are the design issues for an exception handling?
  • 7. Answer 1. Form – a choice between having handlers that are complete programs units or handlers that are code segments. They may be embedded in the units that caused the exception they are to handle or they may be embedded in a different unit, such as the unit that called the one in which the exception is raised.
  • 8. Answer 2. How an exception occurrence is bound to an exception handler – This occurs in two different levels, On the unit level, there is the question of how the same exception being raised at different points in a unit can be bound to different handlers within the unit. It should be possible to bind the exception that can be raised by particular statements to particular handlers, even though the same exception can be raised by many different statements. At the higher level, the binding question arises when there is no exception handler local to the unit in which the exception is raised. If exceptions are propagated, a single handler might handle the same exceptions raised in several program units, which may require the handler to be more general than one would prefer.
  • 9. Answer 3. Whether the binding of exceptions to handlers is static or dynamic , that is , whether binding depends on the syntactic layout of the program or on its execution sequence. As it is in other language constructs, static binding of exceptions is easier to understand and implement than dynamic binding.
  • 10. Answer 4. If users are allowed to define exceptions, how are there exceptions specified? The usual answer is to require that they be declared in the specifications parts of the program units in which they can be raised. 5. Whether built in exceptions can be raised explicitly by the user program. This can be convenient if there are software – detectable situations in which the user would like to use a built- handler.
  • 11. Answer 6. Whether hardware-detectable errors should be treated as exceptions that could be handled by user program. It not, all exceptions obviously are software-detectable. A related question is whether there should be any built in exceptions. 7. Whether exception, either built in or user-defined, can be temporarily or permanently disabled.
  • 12. Question # 3 What does it mean for an exception to be bound to an exception handler?
  • 13. Answer If the block or unit in which an exception is raised does not have a handler for that exception, the exception is propagated elsewhere to be handled – Procedures - propagate it to the caller – Blocks - propagate it to the scope in which it appears – Package body - propagate it to the declaration part of the unit that declared the package (if it is a library unit, the program is terminated)
  • 14. Answer – Task - no propagation; if it haandler, execute it; in either case, mark it "completed --- Sa JAVA Binding an exception to a handler is simpler in Java than it is in C++ – An exception is bound to the first handler with a parameter is the same class as the thrown object or an ancestor of it • An exception can be handled and rethrown by including a throw in the handler (a handler could also throw a different exception)
  • 15. Question # 4 What is the parent class of most Java user-defined exception classes?
  • 16. Answer Throwable class. Based on the book, All Java exceptions are objects of classes that are descendants of the Throwable class
  • 17. Question # 5 How can an exception handler be written in Java so that it handles any exceptions?
  • 18. Answer To ensure that exceptions can be thrown in a try clause are always handled in a method, a special handler can be written that matches all exceptions that are derived from Exception simply by defining the handler with an Exception type parameter as in catch (Exception genericObject) { … }
  • 19. Question # 6 What is the difference between a C++ throw specifications and a Java throws clause?
  • 20. Answer 1. A C++ program can throw any type defined in the program or by the system. In Java, only objects that are instances of Throwable or some class that descends from it can be thrown. 2. A C++ program unit that does not include a throws clause can throw any exception, which tells the reader nothing. A Java method that does not include throws clause cannot throw any checked exceptions that it does not handle. Therefore, the reader of a Java method knows from its header what exceptions it could throw but does not handle.
  • 21. Answer 3. The addition of the finally clause is great convenience in certain situations. It allows cleanup kinds of actions to take place regardless of how a compound statement terminated. 4. The Java run-time system implicitly throws a variety of exceptions, such as for array indices out of range and null reference variable accesses, which can be handled by any user program. A C++ program can handle only those exceptions that it explicitly throws.
  • 22. Question # 7 What is the difference between checked and unchecked exceptions in Java?
  • 23. Answer Checked exceptions are carried out or executed whenever there is an error in the syntax and programming-side while unchecked exceptions hold the errors that might occur during user or data interaction.
  • 24. Question # 8 Can you disable a Java exception?
  • 25. Answer There are exceptions in Java that are automatically invoked when a data-specific error occurs. These exceptions are also called checked exceptions. They cannot be disabled as they are built-in with the Java API. But if you are using an unchecked exception, you may disable it intentionally or unintentionally by using a break; statement just before a line that might throw an exception.
  • 26. Question # 9 What is the purpose of the Java finally clause?
  • 27. Answer Purpose: To specify code that is to be executed, regardless of what happens in the try construct
  • 28. Kristine Ancheta Stephanie Rosanna Blanza Desney Ann Caracot Roshe Nikhka de Guzman Rhys Anton Gabion Erick Lester Sumugat Carlo Mar