This document discusses exception handling in Java. It explains that Java uses try, catch, throw, throws and finally keywords to handle exceptions. Code that could cause exceptions is placed in a try block. Catch blocks are used to handle exceptions. Finally blocks contain code that must execute whether an exception occurs or not, like closing a file. The document provides examples of exception handling code structure and discusses how the Java runtime searches for catch blocks when an exception is thrown.
The exception hierarchy
Exception handling fundamentals
Try and catch
The consequences of an uncaught exception
Using multiple catch statements
Catching subclass exceptions
Nested try blocks
Throwing an exception
Re-throwing an exception
Using finally
Using throws
Java’s built-in exception
Creating exception subclasses
The exception hierarchy
Exception handling fundamentals
Try and catch
The consequences of an uncaught exception
Using multiple catch statements
Catching subclass exceptions
Nested try blocks
Throwing an exception
Re-throwing an exception
Using finally
Using throws
Java’s built-in exception
Creating exception subclasses
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
A workshop hosted by the South African Journal of Science aimed at postgraduate students and early career researchers with little or no experience in writing and publishing journal articles.
This slide is special for master students (MIBS & MIFB) in UUM. Also useful for readers who are interested in the topic of contemporary Islamic banking.
Safalta Digital marketing institute in Noida, provide complete applications that encompass a huge range of virtual advertising and marketing additives, which includes search engine optimization, virtual communication advertising, pay-per-click on marketing, content material advertising, internet analytics, and greater. These university courses are designed for students who possess a comprehensive understanding of virtual marketing strategies and attributes.Safalta Digital Marketing Institute in Noida is a first choice for young individuals or students who are looking to start their careers in the field of digital advertising. The institute gives specialized courses designed and certification.
for beginners, providing thorough training in areas such as SEO, digital communication marketing, and PPC training in Noida. After finishing the program, students receive the certifications recognised by top different universitie, setting a strong foundation for a successful career in digital marketing.
The simplified electron and muon model, Oscillating Spacetime: The Foundation...RitikBhardwaj56
Discover the Simplified Electron and Muon Model: A New Wave-Based Approach to Understanding Particles delves into a groundbreaking theory that presents electrons and muons as rotating soliton waves within oscillating spacetime. Geared towards students, researchers, and science buffs, this book breaks down complex ideas into simple explanations. It covers topics such as electron waves, temporal dynamics, and the implications of this model on particle physics. With clear illustrations and easy-to-follow explanations, readers will gain a new outlook on the universe's fundamental nature.
Delivering Micro-Credentials in Technical and Vocational Education and TrainingAG2 Design
Explore how micro-credentials are transforming Technical and Vocational Education and Training (TVET) with this comprehensive slide deck. Discover what micro-credentials are, their importance in TVET, the advantages they offer, and the insights from industry experts. Additionally, learn about the top software applications available for creating and managing micro-credentials. This presentation also includes valuable resources and a discussion on the future of these specialised certifications.
For more detailed information on delivering micro-credentials in TVET, visit this https://tvettrainer.com/delivering-micro-credentials-in-tvet/
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Executive Directors Chat Leveraging AI for Diversity, Equity, and InclusionTechSoup
Let’s explore the intersection of technology and equity in the final session of our DEI series. Discover how AI tools, like ChatGPT, can be used to support and enhance your nonprofit's DEI initiatives. Participants will gain insights into practical AI applications and get tips for leveraging technology to advance their DEI goals.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
2. Objectives
On completion of this period, you would be able to
know:
• Exception handling mechanism in Java
• How to deal with exceptions
2
3. Recap
• In the previous class, you have studied about the
features and advantages of exceptions
• Advantages are
• Exception is a built-in class in Java
• Separation of logic of program for error handling
section
• Classification of exceptions possible
3
4. Exception Handling Mechanism In Java
• As soon as on exception occurs, the Java runtime
generates an exception object of the required type
• This is known as creating and throwing exception
• It then checks the method, where the exception is
generated, for any code to handle the exception
• This method is known as exception handling code
4
5. Exception Handling Mechanism In Java
Contd . . .
• Then, the runtime system checks for each block in
that method for catch block
• Catch block is known as the exception handler
• If there is no catch block
• The system checks for catch block, in the calling method of
the current method
5
6. Exception Handling Mechanism In Java
Contd . . .
• The system continuously checks nesting methods
until main method in checked
• If the current method is main method, then the
exception message is shown on the error output
• If there is a catch block in any method, the exception
will be handled
6
7. What The Java Run Time Does When An
Exception Occurs ? Contd . . .
• The method call sequence is Method3 without an
exception handler
shown
• The call sequence starts from Method2 without an Method call
the main method exception handler
• main calls Method1
Method1 with an Method call
• Method1 calls Method2
exception handler
• Method2 calls Method3
Method call
main
Fig. 43.1 Call stack
8. Exception Handling Mechanism In Java
Contd . . .
• Here, in Method3 Throws Method3 without an
exception occurs exception exception handler
Looking for
• Method3 does not appropriate
contain the exception handler
Forwards Method2 without an
handler
exception exception handler
• Method3 is called by
method2 which has no Looking for
exception handler Catches Method1 with an appropriate
some exception handler handler
• Method2 is called by exception
method1
• Method1 has exception
main
handler
• In Method1 exception is
handled
Fig. 43.2 Searching the call stack for
exception handler
9. How To Deal With Exceptions
• Java exception handling is managed via five
keywords
• try
• catch
• throw
• throws
• finally
9
10. How To Deal With Exceptions Contd...
• Program statements that you want to monitor for
exceptions are put within a try block
• If an exception occurs within the try block, it is
thrown
• Your code can catch this exception using catch
and handle it in some rational manner
10
11. How To Deal With Exceptions Contd..
• System-generated exceptions are automatically
thrown by the Java run-time system
• To manually throw an exception, use the keyword
throw
11
12. How To Deal With Exceptions Contd..
• Any exception that is thrown out of a method must
be specified as such by a throws clause
• Any code that absolutely must be executed before a
method returns is put in a finally block
• finally block is useful – for writing clean up code
e.g :
To close an opened for file
To close database connection
To re-initialize variable. etc
12
13. Format Of An Exception-Handling Block
try {
// block of code to monitor for errors
}
catch (ExceptionType1 exOb) {
// exception handler for ExceptionType1
}
catch (ExceptionType2 exOb) {
// exception handler for ExceptionType2
}
finally {
// block of code to be executed before try block ends
}
13
14. Discussion
• How many try blocks can be there in a method?
• It depends on the type of exceptions we fore-
see
• How many catch blocks can be there for a try
block?
• Any number of catch blocks
14
15. Summary
• In this class we have discussed
• Exception handling mechanism in java
• The keywords necessary for handling
exceptions
• try, catch, throw, throws and finally
15
16. Quiz
1. Program statements that you want to monitor for
exceptions are put within a try block
A. True
B. False
16