This document discusses exception handling in Java. It defines exceptions as abnormal conditions that disrupt normal program flow. Exception handling allows programs to continue running after exceptions rather than terminating. Key points:
- Exceptions are represented by objects in Java that describe errors.
- try-catch blocks allow handling exceptions within the catch block instead of terminating. finally blocks always execute regardless of exceptions.
- Checked exceptions must be caught or declared to be thrown; unchecked exceptions like NullPointerException represent programmer errors.
- Exceptions propagate up the call stack until caught unless declared as thrown. Exception handling prevents program termination due to errors.
This document provides an introduction to Java exceptions. It discusses what exceptions are, how they are handled using try/catch blocks, and the different types of exceptions including checked, unchecked, and user-defined exceptions. It also covers exception handling best practices such as only catching exceptions where they can be meaningfully handled, using the finally block to close resources, and avoiding empty catch blocks.
This document discusses Java exception handling. It covers the exception hierarchy, keywords like try, catch, throw, throws and finally. It explains how to handle exceptions, create custom exception subclasses, and Java's built-in exceptions. Exception handling allows programs to define error handling blocks to gracefully handle runtime errors rather than crashing.
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
Ch-1_5.pdf this is java tutorials for allHayomeTakele
The document discusses exception handling in Java. It defines exceptions as abnormal conditions that occur during runtime and disrupt normal program flow. It describes different types of exceptions like checked, unchecked, and errors. It explains concepts like exception handling syntax using try, catch, finally blocks to maintain program flow. It provides examples to demonstrate exception handling and resolving exceptions in catch blocks.
The document discusses exception handling and multithreading in Java. It defines exceptions as unexpected events that occur during program execution and disrupt normal flow. There are three types of exceptions: checked exceptions which occur at compile time; unchecked exceptions which occur at runtime; and errors which are problems beyond a program's control. The try, catch, finally keywords are used to handle exceptions. The document also discusses creating threads and synchronization in multithreaded programming.
The document discusses exception handling and multithreading in Java. It begins by defining exceptions as unexpected events that occur during program execution and disrupt normal flow. There are three categories of exceptions: checked exceptions which occur at compile time; unchecked exceptions which occur at runtime; and errors which are problems beyond a program's control. The document then covers how to handle exceptions using try, catch, finally and throw keywords. It provides examples of built-in and user-defined exceptions. The document concludes by explaining Java's multithreading model, how to create and manage threads, set thread priorities and states, and techniques for inter-thread communication.
The document discusses exception handling in Java. It defines exceptions as abnormal conditions that disrupt normal program flow. Exception handling allows programs to gracefully handle runtime errors. The key types of exceptions are checked exceptions, unchecked exceptions, and errors. The try-catch block is used to catch exceptions, with catch blocks handling specific exception types. Custom exceptions can also be created to customize exception handling.
The document discusses Java exceptions. It defines exceptions as abnormal conditions that disrupt normal program flow. It describes different types of exceptions like checked exceptions, unchecked exceptions, and errors. It explains exception handling in Java using try, catch, finally, throw and throws keywords. It provides examples to demonstrate various exceptions like NullPointerException, ArrayIndexOutOfBoundsException, and rethrowing exceptions.
The document provides an overview of exceptions in Java. It defines errors and exceptions, describes different types of exceptions including checked and unchecked exceptions, and explains key exception handling keywords like try, catch, throw, throws, and finally. The document aims to help programmers better understand exceptions and how to properly handle errors in their Java code.
Exception handling in Java allows programs to gracefully handle errors and unexpected conditions. There are two main types of exceptions - checked exceptions that must be declared and handled, and unchecked exceptions that do not require declaration. The try-catch block is used to catch and handle exceptions, while the finally block always executes to clean up resources regardless of whether an exception occurred or not. Custom exceptions can also be created to generate application-specific error messages.
Exception handling in Java allows programs to deal with errors and unexpected conditions gracefully. The try block encloses code that might throw exceptions. When an exception is thrown, the runtime system searches the call stack for a catch block that can handle the exception. The finally block always executes after the try and catch blocks complete to ensure cleanup code runs. Custom exceptions can be created by extending the Exception class.
UNIT-3.pptx Exception Handling and MultithreadingSakkaravarthiS1
The document discusses exception handling and multithreading in Java. It covers exception handling basics like checked and unchecked exceptions. It describes try, catch, throw, throws and finally keywords used in exception handling. It also discusses multiple catch clauses, nested try blocks and built-in exceptions. For multithreading, it defines processes and threads, and how to create multiple threads and handle thread synchronization and priorities in Java.
This document provides an overview of flow control and exceptions in Java. It discusses if and switch statements, loops like while, do and for loops, break and continue statements, labeled statements, and exceptions. For exceptions, it covers try/catch/finally blocks, checked and unchecked exceptions, and creating custom exceptions. It also lists common Java exceptions and provides example code links for various concepts.
Exceptions in Java represent errors or abnormal conditions that occur during program execution. When an exception is thrown, it disrupts the normal flow of execution. Exceptions can be handled using try/catch blocks. The try block contains code that might throw exceptions. Corresponding catch blocks handle specific exception types if they occur. Finally blocks contain cleanup code that always executes regardless of exceptions.
The document discusses exception handling in Java. It introduces exceptions as conditions caused by runtime errors and how exception handling helps detect and report these "exceptional circumstances." It explains the types of errors like runtime, logic, and syntax errors. It provides examples of exception handling using try-catch blocks to handle exceptions locally or declaring throws to pass exceptions to other methods. Finally, it discusses standard Java exceptions and provides code examples demonstrating exception handling.
The document discusses exception handling in Java. It defines exceptions as problems that disrupt normal program flow. Exceptions can be caused by invalid user input, file errors, or other issues. Java exceptions are categorized as checked, unchecked, or errors. Checked exceptions must be caught or declared, while unchecked exceptions and errors typically are not. The try-catch block allows catching and handling exceptions. The catch block contains code to handle exceptions thrown in the try block. Exception handling allows programs to continue running after exceptions rather than crashing.
This document discusses exception handling in Java. It defines errors and exceptions, and describes different types of exceptions like compile-time errors, runtime errors, checked exceptions and unchecked exceptions. It explains the steps in exception handling using try, catch, throw and throws keywords. Examples of different exceptions like ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException are provided. Finally, it covers exception handling mechanisms like multiple catch blocks, nested try blocks, and user-defined exceptions.
The document discusses exception handling in Java, including:
1) What exceptions are and how exception handling prevents programs from terminating due to exceptions.
2) The main keywords used in exception handling like try, catch, finally, and throws.
3) The exception hierarchy in Java and differences between checked and unchecked exceptions.
4) Examples of built-in exceptions like FileNotFoundException and how to create custom exceptions.
unit 4 msbte syallbus for sem 4 2024-2025AKSHAYBHABAD5
The Intel 8086 microprocessor, designed by Intel in the late 1970s, is an 8-bit/16-bit microprocessor and the first member of the x86 family of microprocessors1. Here’s a brief overview of its internal architecture:
Complex Instruction Set Computer (CISC) Architecture: The 8086 microprocessor is based on a CISC architecture, which supports a wide range of instructions, many of which can perform multiple operations in a single instruction1.
Bus Interface Unit (BIU): The BIU is responsible for fetching instructions from memory and decoding them, while also managing data transfer between the microprocessor and memory or I/O devices1.
Execution Unit (EU): The EU executes the instructions1.
Memory Segmentation: The 8086 microprocessor has a segmented memory architecture, which means that memory is divided into segments that are addressed using both a segment register and an offset1.
Registers: The 8086 microprocessor has a rich set of registers, including general-purpose registers, segment registers, and special registers
The document discusses exception handling in Java. It defines exceptions as events that prevent an action from completing as intended. There are three types of exceptions: errors thrown by the JVM, runtime exceptions for logical errors, and checked exceptions for external issues. The try-catch block is used to handle exceptions, with catch blocks for specific exception types and finally for cleanup. Custom exceptions can be created by extending the Exception class.
This document discusses exception handling in Java. It defines exceptions as objects that describe errors during code execution. The try, catch, and finally keywords are used to handle exceptions. Exceptions can be generated by the Java runtime system or manually coded. The try block contains code that could cause exceptions. Catch blocks handle specific exception types. Finally blocks contain cleanup code. All exceptions extend the Throwable class. The Exception class is for program exceptions, while Error is for environmental errors. Uncaught exceptions use the default exception handler.
Ch-1_5.pdf this is java tutorials for allHayomeTakele
The document discusses exception handling in Java. It defines exceptions as abnormal conditions that occur during runtime and disrupt normal program flow. It describes different types of exceptions like checked, unchecked, and errors. It explains concepts like exception handling syntax using try, catch, finally blocks to maintain program flow. It provides examples to demonstrate exception handling and resolving exceptions in catch blocks.
The document discusses exception handling and multithreading in Java. It defines exceptions as unexpected events that occur during program execution and disrupt normal flow. There are three types of exceptions: checked exceptions which occur at compile time; unchecked exceptions which occur at runtime; and errors which are problems beyond a program's control. The try, catch, finally keywords are used to handle exceptions. The document also discusses creating threads and synchronization in multithreaded programming.
The document discusses exception handling and multithreading in Java. It begins by defining exceptions as unexpected events that occur during program execution and disrupt normal flow. There are three categories of exceptions: checked exceptions which occur at compile time; unchecked exceptions which occur at runtime; and errors which are problems beyond a program's control. The document then covers how to handle exceptions using try, catch, finally and throw keywords. It provides examples of built-in and user-defined exceptions. The document concludes by explaining Java's multithreading model, how to create and manage threads, set thread priorities and states, and techniques for inter-thread communication.
The document discusses exception handling in Java. It defines exceptions as abnormal conditions that disrupt normal program flow. Exception handling allows programs to gracefully handle runtime errors. The key types of exceptions are checked exceptions, unchecked exceptions, and errors. The try-catch block is used to catch exceptions, with catch blocks handling specific exception types. Custom exceptions can also be created to customize exception handling.
The document discusses Java exceptions. It defines exceptions as abnormal conditions that disrupt normal program flow. It describes different types of exceptions like checked exceptions, unchecked exceptions, and errors. It explains exception handling in Java using try, catch, finally, throw and throws keywords. It provides examples to demonstrate various exceptions like NullPointerException, ArrayIndexOutOfBoundsException, and rethrowing exceptions.
The document provides an overview of exceptions in Java. It defines errors and exceptions, describes different types of exceptions including checked and unchecked exceptions, and explains key exception handling keywords like try, catch, throw, throws, and finally. The document aims to help programmers better understand exceptions and how to properly handle errors in their Java code.
Exception handling in Java allows programs to gracefully handle errors and unexpected conditions. There are two main types of exceptions - checked exceptions that must be declared and handled, and unchecked exceptions that do not require declaration. The try-catch block is used to catch and handle exceptions, while the finally block always executes to clean up resources regardless of whether an exception occurred or not. Custom exceptions can also be created to generate application-specific error messages.
Exception handling in Java allows programs to deal with errors and unexpected conditions gracefully. The try block encloses code that might throw exceptions. When an exception is thrown, the runtime system searches the call stack for a catch block that can handle the exception. The finally block always executes after the try and catch blocks complete to ensure cleanup code runs. Custom exceptions can be created by extending the Exception class.
UNIT-3.pptx Exception Handling and MultithreadingSakkaravarthiS1
The document discusses exception handling and multithreading in Java. It covers exception handling basics like checked and unchecked exceptions. It describes try, catch, throw, throws and finally keywords used in exception handling. It also discusses multiple catch clauses, nested try blocks and built-in exceptions. For multithreading, it defines processes and threads, and how to create multiple threads and handle thread synchronization and priorities in Java.
This document provides an overview of flow control and exceptions in Java. It discusses if and switch statements, loops like while, do and for loops, break and continue statements, labeled statements, and exceptions. For exceptions, it covers try/catch/finally blocks, checked and unchecked exceptions, and creating custom exceptions. It also lists common Java exceptions and provides example code links for various concepts.
Exceptions in Java represent errors or abnormal conditions that occur during program execution. When an exception is thrown, it disrupts the normal flow of execution. Exceptions can be handled using try/catch blocks. The try block contains code that might throw exceptions. Corresponding catch blocks handle specific exception types if they occur. Finally blocks contain cleanup code that always executes regardless of exceptions.
The document discusses exception handling in Java. It introduces exceptions as conditions caused by runtime errors and how exception handling helps detect and report these "exceptional circumstances." It explains the types of errors like runtime, logic, and syntax errors. It provides examples of exception handling using try-catch blocks to handle exceptions locally or declaring throws to pass exceptions to other methods. Finally, it discusses standard Java exceptions and provides code examples demonstrating exception handling.
The document discusses exception handling in Java. It defines exceptions as problems that disrupt normal program flow. Exceptions can be caused by invalid user input, file errors, or other issues. Java exceptions are categorized as checked, unchecked, or errors. Checked exceptions must be caught or declared, while unchecked exceptions and errors typically are not. The try-catch block allows catching and handling exceptions. The catch block contains code to handle exceptions thrown in the try block. Exception handling allows programs to continue running after exceptions rather than crashing.
This document discusses exception handling in Java. It defines errors and exceptions, and describes different types of exceptions like compile-time errors, runtime errors, checked exceptions and unchecked exceptions. It explains the steps in exception handling using try, catch, throw and throws keywords. Examples of different exceptions like ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException are provided. Finally, it covers exception handling mechanisms like multiple catch blocks, nested try blocks, and user-defined exceptions.
The document discusses exception handling in Java, including:
1) What exceptions are and how exception handling prevents programs from terminating due to exceptions.
2) The main keywords used in exception handling like try, catch, finally, and throws.
3) The exception hierarchy in Java and differences between checked and unchecked exceptions.
4) Examples of built-in exceptions like FileNotFoundException and how to create custom exceptions.
unit 4 msbte syallbus for sem 4 2024-2025AKSHAYBHABAD5
The Intel 8086 microprocessor, designed by Intel in the late 1970s, is an 8-bit/16-bit microprocessor and the first member of the x86 family of microprocessors1. Here’s a brief overview of its internal architecture:
Complex Instruction Set Computer (CISC) Architecture: The 8086 microprocessor is based on a CISC architecture, which supports a wide range of instructions, many of which can perform multiple operations in a single instruction1.
Bus Interface Unit (BIU): The BIU is responsible for fetching instructions from memory and decoding them, while also managing data transfer between the microprocessor and memory or I/O devices1.
Execution Unit (EU): The EU executes the instructions1.
Memory Segmentation: The 8086 microprocessor has a segmented memory architecture, which means that memory is divided into segments that are addressed using both a segment register and an offset1.
Registers: The 8086 microprocessor has a rich set of registers, including general-purpose registers, segment registers, and special registers
The document discusses exception handling in Java. It defines exceptions as events that prevent an action from completing as intended. There are three types of exceptions: errors thrown by the JVM, runtime exceptions for logical errors, and checked exceptions for external issues. The try-catch block is used to handle exceptions, with catch blocks for specific exception types and finally for cleanup. Custom exceptions can be created by extending the Exception class.
This document discusses exception handling in Java. It defines exceptions as objects that describe errors during code execution. The try, catch, and finally keywords are used to handle exceptions. Exceptions can be generated by the Java runtime system or manually coded. The try block contains code that could cause exceptions. Catch blocks handle specific exception types. Finally blocks contain cleanup code. All exceptions extend the Throwable class. The Exception class is for program exceptions, while Error is for environmental errors. Uncaught exceptions use the default exception handler.
This document discusses schema refinement through normalization. Schema refinement aims to eliminate data redundancy and anomalies like insertion, update, and deletion anomalies. It introduces normalization as a technique to decompose tables and refine the schema. Redundancy can lead to problems like redundant storage, update anomalies if one copy of data is changed without updating others, and insertion and deletion anomalies where adding or removing data could impact unrelated information. The document uses an example of a student details table to illustrate these problems and how decomposition can address redundancy.
joins in dbms its describes about how joins are important and necessity in d...AshokRachapalli1
Joins in DBMS allow combining data from multiple tables. Inner joins return rows where the join condition is satisfied, while outer joins also return rows with no matches and fill unmatched columns with NULL. Natural joins automatically join on common columns with matching names and domains, while theta joins use any comparison operator in the join condition. Equi joins specifically use equality comparisons.
Database languages are used to define, manipulate, and control access to data in a database management system. There are four main types of database languages: Data Definition Language (DDL) defines the database structure; Data Manipulation Language (DML) reads, inserts, updates, and deletes data; Data Control Language (DCL) controls user access privileges; and Transaction Control Language (TCL) manages transactions and rolling back or committing changes to the database.
The document discusses register transfer languages (RTL) which are used to specify the operations and timing of digital circuits. It covers micro-operations which define data transfers, RTL which specifies when micro-operations occur, and how RTL specifications can be realized through hardware implementation or simulated using VHDL. Examples are provided of RTL specifications for simple counters and controllers to illustrate these concepts.
The document discusses different levels of computer memory and cache memory. It describes four levels of memory:
1) Register - Stores data accepted by the CPU.
2) Cache memory - Faster memory that temporarily stores frequently accessed data from main memory.
3) Main memory - The memory the computer currently works on but data is lost when powered off.
4) Secondary memory - External memory that stores data permanently but is slower than main memory.
It then discusses cache memory in more detail, describing it as very high-speed memory that stores copies of frequently used data from main memory to reduce average access time. It explains the concepts of cache hits, misses, and hit ratio. Finally, it
The document discusses different types of addressing modes used in computer instructions, including implied, immediate, direct, indirect, register direct, register indirect, relative, indexed, base register, auto-increment, and auto-decrement addressing modes. It provides examples and explanations of each addressing mode type.
The document discusses input/output (I/O) organization in a computer system. It describes I/O interfaces that allow communication between internal storage and external devices. Data transfer can occur via programmed I/O, interrupt-initiated I/O, or direct memory access (DMA). DMA allows direct transfer between I/O devices and memory without CPU involvement by using a DMA controller. An I/O processor (IOP) is also described, which is a dedicated processor that handles I/O operations and transfers data between devices and memory.
Virtual memory allows programs to access memory addresses that do not physically exist, expanding the available address space. It works by dividing memory into pages that are stored on disk until needed, then copied into RAM. When a program accesses a non-present page, a page fault occurs and the operating system handles copying the correct page into memory transparently to the program. This allows more programs to run than would otherwise fit in physical memory.
How to Manage Opening & Closing Controls in Odoo 17 POSCeline George
In Odoo 17 Point of Sale, the opening and closing controls are key for cash management. At the start of a shift, cashiers log in and enter the starting cash amount, marking the beginning of financial tracking. Throughout the shift, every transaction is recorded, creating an audit trail.
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...Celine George
Analytic accounts are used to track and manage financial transactions related to specific projects, departments, or business units. They provide detailed insights into costs and revenues at a granular level, independent of the main accounting system. This helps to better understand profitability, performance, and resource allocation, making it easier to make informed financial decisions and strategic planning.
A measles outbreak originating in West Texas has been linked to confirmed cases in New Mexico, with additional cases reported in Oklahoma and Kansas. The current case count is 795 from Texas, New Mexico, Oklahoma, and Kansas. 95 individuals have required hospitalization, and 3 deaths, 2 children in Texas and one adult in New Mexico. These fatalities mark the first measles-related deaths in the United States since 2015 and the first pediatric measles death since 2003.
The YSPH Virtual Medical Operations Center Briefs (VMOC) were created as a service-learning project by faculty and graduate students at the Yale School of Public Health in response to the 2010 Haiti Earthquake. Each year, the VMOC Briefs are produced by students enrolled in Environmental Health Science Course 581 - Public Health Emergencies: Disaster Planning and Response. These briefs compile diverse information sources – including status reports, maps, news articles, and web content– into a single, easily digestible document that can be widely shared and used interactively. Key features of this report include:
- Comprehensive Overview: Provides situation updates, maps, relevant news, and web resources.
- Accessibility: Designed for easy reading, wide distribution, and interactive use.
- Collaboration: The “unlocked" format enables other responders to share, copy, and adapt seamlessly. The students learn by doing, quickly discovering how and where to find critical information and presenting it in an easily understood manner.
A measles outbreak originating in West Texas has been linked to confirmed cases in New Mexico, with additional cases reported in Oklahoma and Kansas. The current case count is 817 from Texas, New Mexico, Oklahoma, and Kansas. 97 individuals have required hospitalization, and 3 deaths, 2 children in Texas and one adult in New Mexico. These fatalities mark the first measles-related deaths in the United States since 2015 and the first pediatric measles death since 2003.
The YSPH Virtual Medical Operations Center Briefs (VMOC) were created as a service-learning project by faculty and graduate students at the Yale School of Public Health in response to the 2010 Haiti Earthquake. Each year, the VMOC Briefs are produced by students enrolled in Environmental Health Science Course 581 - Public Health Emergencies: Disaster Planning and Response. These briefs compile diverse information sources – including status reports, maps, news articles, and web content– into a single, easily digestible document that can be widely shared and used interactively. Key features of this report include:
- Comprehensive Overview: Provides situation updates, maps, relevant news, and web resources.
- Accessibility: Designed for easy reading, wide distribution, and interactive use.
- Collaboration: The “unlocked" format enables other responders to share, copy, and adapt seamlessly. The students learn by doing, quickly discovering how and where to find critical information and presenting it in an easily understood manner.
CURRENT CASE COUNT: 817 (As of 05/3/2025)
• Texas: 688 (+20)(62% of these cases are in Gaines County).
• New Mexico: 67 (+1 )(92.4% of the cases are from Eddy County)
• Oklahoma: 16 (+1)
• Kansas: 46 (32% of the cases are from Gray County)
HOSPITALIZATIONS: 97 (+2)
• Texas: 89 (+2) - This is 13.02% of all TX cases.
• New Mexico: 7 - This is 10.6% of all NM cases.
• Kansas: 1 - This is 2.7% of all KS cases.
DEATHS: 3
• Texas: 2 – This is 0.31% of all cases
• New Mexico: 1 – This is 1.54% of all cases
US NATIONAL CASE COUNT: 967 (Confirmed and suspected):
INTERNATIONAL SPREAD (As of 4/2/2025)
• Mexico – 865 (+58)
‒Chihuahua, Mexico: 844 (+58) cases, 3 hospitalizations, 1 fatality
• Canada: 1531 (+270) (This reflects Ontario's Outbreak, which began 11/24)
‒Ontario, Canada – 1243 (+223) cases, 84 hospitalizations.
• Europe: 6,814
GDGLSPGCOER - Git and GitHub Workshop.pptxazeenhodekar
This presentation covers the fundamentals of Git and version control in a practical, beginner-friendly way. Learn key commands, the Git data model, commit workflows, and how to collaborate effectively using Git — all explained with visuals, examples, and relatable humor.
Exploring Substances:
Acidic, Basic, and
Neutral
Welcome to the fascinating world of acids and bases! Join siblings Ashwin and
Keerthi as they explore the colorful world of substances at their school's
National Science Day fair. Their adventure begins with a mysterious white paper
that reveals hidden messages when sprayed with a special liquid.
In this presentation, we'll discover how different substances can be classified as
acidic, basic, or neutral. We'll explore natural indicators like litmus, red rose
extract, and turmeric that help us identify these substances through color
changes. We'll also learn about neutralization reactions and their applications in
our daily lives.
by sandeep swamy
The ever evoilving world of science /7th class science curiosity /samyans aca...Sandeep Swamy
The Ever-Evolving World of
Science
Welcome to Grade 7 Science4not just a textbook with facts, but an invitation to
question, experiment, and explore the beautiful world we live in. From tiny cells
inside a leaf to the movement of celestial bodies, from household materials to
underground water flows, this journey will challenge your thinking and expand
your knowledge.
Notice something special about this book? The page numbers follow the playful
flight of a butterfly and a soaring paper plane! Just as these objects take flight,
learning soars when curiosity leads the way. Simple observations, like paper
planes, have inspired scientific explorations throughout history.
This chapter provides an in-depth overview of the viscosity of macromolecules, an essential concept in biophysics and medical sciences, especially in understanding fluid behavior like blood flow in the human body.
Key concepts covered include:
✅ Definition and Types of Viscosity: Dynamic vs. Kinematic viscosity, cohesion, and adhesion.
⚙️ Methods of Measuring Viscosity:
Rotary Viscometer
Vibrational Viscometer
Falling Object Method
Capillary Viscometer
🌡️ Factors Affecting Viscosity: Temperature, composition, flow rate.
🩺 Clinical Relevance: Impact of blood viscosity in cardiovascular health.
🌊 Fluid Dynamics: Laminar vs. turbulent flow, Reynolds number.
🔬 Extension Techniques:
Chromatography (adsorption, partition, TLC, etc.)
Electrophoresis (protein/DNA separation)
Sedimentation and Centrifugation methods.
2. What is an Exception in Java?
• An exception is an unwanted or unexpected event that occurs
during the execution of the program, that disrupts the flow of
the program.
• For example, if a user is trying to divide an integer by 0 then it
is an exception, as it is not possible mathematically.
• There are various types of interruptions while executing any
program like errors, exceptions, and bugs. These interruptions
can be due to programming mistakes or due to system issues.
Depending on the conditions they can be classified as errors
and exceptions.
• Java has classes that are used to handle built-in exceptions and
provision to create user-defined exceptions.
3. 1. Exception
• Exceptions are unwanted conditions that disrupt the
flow of the program.
• Exceptions usually occur due to the code and can be
recovered.
• Exceptions can be of both checked(exceptions that are
checked by the compiler) and unchecked(exceptions
that cannot be checked by the compiler) type.
• They can occur at both run time and compile time.
• In Java, exceptions belong to java.lang.Exception class.
4. 2. Error
• An error is also an unwanted condition but it is
caused due to lack of resources and indicates a
serious problem.
• Errors are irrecoverable, they cannot be handled
by the programmers.
• Errors are of unchecked type only.
• They can occur only at run time.
• In java, errors belong to java.lang.error class.
• Eg: OutOfMemmoryError.
5. What is Exception Handling in java?
• Exception handling in java is a mechanism to handle
unwanted interruptions like exceptions and
continue with the normal flow of the program.
• Java uses try-catch blocks and other keywords like
finally, throw, and throws to handle exceptions.
• JVM(Java Virtual Machine) by default handles
exceptions, when an exception is raised it will halt
the execution of the program and throw the
occurred exception.
6. Why Handle Java Exception?
• We handle exceptions in java to make sure the program
executes properly without any halt, which occurs when an
exception is raised.
• These exceptions are runtime as well as compile-time.
• They may be minor exceptions but can cause a problem in
executions of the program, hence it becomes necessary to
handle java exceptions. If java exceptions are not handled,
programs may crash and execution is halted in between.
• For example, if there is a program with some lines of code and
an exception occurs a mid-way after executing certain lines of
code, in this case, the execution terminates abruptly.
• But if the programmer handles the exceptions explicitly, all the
statements of code are executed properly and the flow of the
program is maintained.
7. Example program
• class SampleCode
• {
• public static void main(String args[])
• {
• Sysytem.out.println("Hello World!");
• int a = 10;
• int b = 0;
• System.out.println(a / b);
• System.out.println("Welcome to java programming.");
• System.out.println("Bye.")
• }
• }
8. Output
• Hello World!
• Exception in thread "main" java.lang.ArithmeticException: / by zero
• at SampleException.main(SampleException.java:8)
• In the above code, the first three lines in the main method
are executed properly.
• At the 4th line, an integer is divided by 0, which is not
possible and an exception is raised by JVM(Java Virtual
Machine).
• In this case, the exception is not handled by the
programmer which will halt the program in between by
throwing the exception, and the rest of the lines of code
won't be executed.
9. How does JVM handles an Exception?
• Java exceptions raised during the program execution are nothing but objects of
the respective exception class in the hierarchy shown above.
• The exceptions have a naming and inheritance hierarchy to the main exception
class in java i.e. Throwable class.
• All java exception objects support the toString() method, which returns the full
name of the exception class as an output to the command prompt, which helps
to understand the exceptional condition.
• Whenever an exception has occurred inside a method, the method creates an
exception object and hands it over to JVM.
• This object contains the name and description of the exception and the current
state of the program where the exception has occurred.
• This is called the process of object creation and handing it over to JVM is known
as throwing an Exception.
• This object is an exception that is further handled by JVM.
10. How does JVM handles an Exception?
• When an exception is raised there is an ordered list of
the methods that had been called by JVM to get the
method where the exception has occurred this list is
called Call Stack.
• JVM searches through this call stack to get the proper
code to handle the occurred exception, this code
block is known as an Exception handler.
• When an appropriate handler is found JVM handles
the exception according to the code in the handler
and shows the state of the program.
11. Major reasons why an exception Occurs
• Invalid user input
• Device failure
• Loss of network connection
• Physical limitations (out-of-disk memory)
• Code errors
• Out of bound
• Null reference
• Type mismatch
• Opening an unavailable file
• Database errors
• Arithmetic errors
12. Hierarchy of Java Exception Classes
• As java is an object-oriented language every
class extends the Object class. All exceptions
and errors are subclasses of class Throwable.
• Throwable is the base/superclass of exception
handling hierarchy in java. This class is further
extended in different classes like exception,
error, and so on.
13. Exception Hierarchy
• All exception and error types are subclasses of the
class Throwable, which is the base class of the hierarchy.
• One branch is headed by Exception. This class is used for
exceptional conditions that user programs should catch.
NullPointerException is an example of such an exception.
• Another branch, Error is used by the Java run-time
system(JVM) to indicate errors having to do with the
run-time environment itself(JRE). StackOverflowError is
an example of such an error.
16. Types of Exceptions
• Java defines several types of exceptions that relate to its various class
libraries. Java also allows users to define their own exceptions.
17. Types of Exceptions Handling in Java
• 1. Checked Exceptions
• Checked exceptions are those exceptions that are
checked at compile time by the compiler.
• The program will not compile if they are not handled.
• These exceptions are child classes of the Exception
class.
• IOException, ClassNotFoundException,
InvocationTargetException, and SQL Exception are a
few of the checked exceptions in Java.
18. Types of Exceptions Handling in Java
• 2. Unchecked Exceptions
• Unchecked exceptions are those exceptions that are
checked at run time by JVM, as the compiler cannot
check unchecked exceptions,
• The programs with unchecked exceptions get compiled
successfully but they give runtime errors if not handled.
• These are child classes of Runtime Exception Class.
• ArithmeticException, NullPointerException,
NumberFormatException, IndexOutOfBoundException
are a few of the unchecked exceptions in Java.
19. How does a Programmer Handles an
Exception?
• Customized exception handling in java is achieved using
five keywords: try, catch, throw, throws, and finally. Here
is how these keywords work in short.
• Try block contains the program statements that may
raise an exception.
• Catch block catches the raised exception and handles it.
• Throw keyword is used to explicitly throw an exception.
• Throws keyword is used to declare an exception.
• Finally block contains statements that must be executed
after the try block.
20. Example of Exception Handling in Java
• class ExceptionExample {
• public static void main(String args[]) {
• try {
• // Code that can raise exception
• int div = 509 / 0;
• } catch (ArithmeticException e) {
• System.out.println(e);
• }
• System.out.println("End of code");
• }
• }
• Output:
• java.lang.ArithmeticException: / by zero
• End of code
21. 1. try block
• try block is used to execute doubtful statements which can throw exceptions.
• try block can have multiple statements.
• Try block cannot be executed on itself, there has to be at least one catch block
or finally block with a try block.
• When any exception occurs in a try block, the appropriate exception object
will be redirected to the catch block, this catch block will handle the
exception according to statements in it and continue the further execution.
• The control of execution goes from the try block to the catch block once an
exception occurs.
• Syntax
• try {
• //Doubtfull Statements.
• }
22. 2. catch block
• catch block is used to give a solution or alternative for an exception.
• catch block is used to handle the exception by declaring the type of
exception within the parameter.
• The declared exception must be the parent class exception or the generated
exception type in the exception class hierarchy or a user-defined exception.
• You can use multiple catch blocks with a single try block.
• Syntax
• try {
• //Doubtful Statements
• }
• catch(Exception e)
• {
• }
23. 1. try-catch block
• public class Main {
• public static void main(String[ ] args) {
• try {
• int[] myNumbers = {10, 1, 2, 3, 5, 11};
• System.out.println(myNumbers[10]);
• } catch (Exception e) {
• System.out.println("Something went wrong.");
• }
• }
• }
• Output:
• Something went wrong.
24. • In this program, the user has declared an array
myNumbers in the try block, which has some
numbers stored in it. And the user is trying to access
an element of the array that is stored at the 10th
position.
• But array has only 6 elements and the highest
address position is 5. By doing this user is trying to
access an element that is not present in the array,
this will raise an exception, and the catch block will
get executed.
25. 2. Multiple Catch Blocks
• Java can have a single try block and multiple
catch blocks and a relevant catch block gets
executed.
• Example 1:
• Here we are giving doubtful statements in a
try block and using multiple catch blocks to
handle the exception that will occur according
to the statement.
26. • public class MultipleCatchBlock1 {
• public static void main(String[] args) {
• try {
• int a[] = new int[5];
• a[5] = 30 / 0;
• } catch (ArithmeticException e) {
• System.out.println("Arithmetic Exception occurs");
• } catch (ArrayIndexOutOfBoundsException e) {
• System.out.println("ArrayIndexOutOfBounds Exception occurs");
• } catch (Exception e) {
• System.out.println("Parent Exception occurs");
• }
• System.out.println("End of the code");
• }
• }
• Output:
• Arithmetic Exception occurs
• End of the code
27. • In this example, the try block has doubtful statements that
are trying to divide an integer by 0 and 3 catch blocks which
have mentioned the exceptions that can handle.
• After execution of the try block, the Arithmetic Exception is
raised and JVM starts to search for the catch block to handle
the same.
• JVM will find the first catch block that can handle the raised
exception, and control will be passed to that catch block.
• After the exception is handled the flow of the program
comes out from try-catch block and it will execute the rest
of the code.
28. • public class MultipleCatchBlock2 {
• public static void main(String[] args) {
• try {
• int a[] = new int[5];
• System.out.println(a[10]);
• } catch (ArithmeticException e) {
• System.out.println("Arithmetic Exception occurs");
• } catch (ArrayIndexOutOfBoundsException e) {
• System.out.println("ArrayIndexOutOfBounds Exception occurs");
• } catch (Exception e) {
• System.out.println("Parent Exception occurs");
• }
• System.out.println("rest of the code");
• }
• }
• Output:
• ArrayIndexOutOfBounds Exception occurs
• rest of the code
29. • In this example, try block has doubtful statements that are trying
to access elements that are not present in an array and 3 catch
blocks that have mentioned the exceptions that can handle.
• After execution of try block, ArrayIndexOutOfBounds Exception is
raised and JVM starts to search for the catch block to handle the
same.
• JVM will find the second catch block that can handle the raised
exception, and control will be passed to that catch block.
• After the exception is handled the flow of the program comes
out from try-catch block and it will execute rest of the code.
30. 3. Nested Try Catch
• class NestingDemo {
• public static void main(String args[]) {
• //main try-block
• try {
• //try-block2
• try {
• //try-block3
• try {
• int arr[] = {
• 1,
• 2,
• 3,
• 4
• };
• /* I'm trying to display the value of
• * an element which doesn't exist. The
• * code should throw an exception
• */
• System.out.println(arr[10]);
• } catch (ArithmeticException e) {
• System.out.print("Arithmetic Exception");
• System.out.println(" handled in try-block3");
• }
• } catch (ArithmeticException e) {
• System.out.print("Arithmetic Exception");
• System.out.println(" handled in try-block2");
• }
• } catch (ArithmeticException e3) {
• System.out.print("Arithmetic Exception");
• System.out.println(" handled in main try-block");
• } catch (ArrayIndexOutOfBoundsException e4) {
• System.out.print("ArrayIndexOutOfBoundsException");
• System.out.println(" handled in main try-block");
• } catch (Exception e5) {
• System.out.print("Exception");
• System.out.println(" handled in main try-block");
• }
• }
• }
• Output:
• ArrayIndexOutOfBoundsException handled in main try-block
31. 3. Nested Try Catch
• As you can see that the ArrayIndexOutOfBoundsException
occurred in the grandchild try-block3.
• Since try-block3 is not handling this exception, the control
then gets transferred to the parent try-block2 and looked for
the catch handlers in try-block2.
• Since the try-block2 is also not handling that exception, the
control gets transferred to the main (grandparent) try-block
where it found the appropriate catch block for an exception.
• We can use the finally block after the main try-catch block if
required.
32. 4. finally block
• finally block is associated with a try, catch block.
• It is executed every time irrespective of
exception is thrown or not.
• finally block is used to execute important
statements such as closing statement, release
the resources, and release memory also.
• finally block can be used with try block with or
without catch block.
34. Example:
• public class Main {
• public static void main(String[] args) {
• try {
• int data = 100/0;
• System.out.println(data);
• } catch (Exception e) {
• System.out.println("Can't divide integer by 0!");
• } finally {
• System.out.println("The 'try catch' is finished.");
• }
• }
• }
• Output:
• Can't divide integer by 0!
• The 'try catch' is finished.
• Here, after the execution of try and catch blocks, finally block gets executed. finally block gets
executed even if the catch block is not executed.
35. throw
• The throw keyword in Java is used to explicitly throw an exception
from a method or any block of code. We can throw either checked or
unchecked exception. The throw keyword is mainly used to throw
custom exceptions.
• Syntax in Java throw
• throw Instance
• Example:
• throw new ArithmeticException("/ by zero");
• But this exception i.e., Instance must be of type Throwable or a
subclass of Throwable.
36. Throw Keyword
• The flow of execution of the program stops
immediately after the throw statement is
executed and the nearest enclosing try block is
checked to see if it has a catch statement that
matches the type of exception.
• If it finds a match, controlled is transferred to
that statement otherwise next
enclosing try block is checked, and so on.
• If no matching catch is found then the default
exception handler will halt the program.
37. Throw Keyword
• // Java program that demonstrates the use of throw
• class ThrowExcep {
• static void fun()
• {
• try {
• throw new NullPointerException("demo");
• }
• catch (NullPointerException e) {
• System.out.println("Caught inside fun().");
• throw e; // rethrowing the exception
• }
• }
• public static void main(String args[])
• {
• try {
• fun();
• }
• catch (NullPointerException e) {
• System.out.println("Caught in main.");
• }
• }
• }
• Output
• Caught inside fun().
• Caught in main.
38. Throw Keyword
• // Java program that demonstrates
• // the use of throw
• class Test {
• public static void main(String[] args)
• {
• System.out.println(1 / 0);
• }
• }
• Output
• Exception in thread "main" java.lang.ArithmeticException: / by zero
39. Java throws
• throws is a keyword in Java that is used in the
signature of a method to indicate that this method
might throw one of the listed type exceptions. The
caller to these methods has to handle the exception
using a try-catch block.
• Syntax of Java throws
• type method_name(parameters) throws
exception_list exception_list is a comma separated
list of all the exceptions which a method might
throw.
40. Java throws
• In a program, if there is a chance of raising an exception then
the compiler always warns us about it and compulsorily we
should handle that checked exception, Otherwise, we will get
compile time error saying unreported exception XXX must be
caught or declared to be thrown. To prevent this compile time
error we can handle the exception in two ways:
• By using try catch
• By using the throws keyword
• We can use the throws keyword to delegate the responsibility
of exception handling to the caller (It may be a method or JVM)
then the caller method is responsible to handle that exception.
41. Java throws Examples
• // Java program to illustrate error in case
• // of unhandled exception
• class tst {
• public static void main(String[] args)
• {
• Thread.sleep(10000);
• System.out.println("Hello Students");
• }
• }
• Output
• error: unreported exception InterruptedException; must be caught or declared to be
thrown
• Explanation
• In the above program, we are getting compile time error because there is a chance of
exception if the main thread is going to sleep, other threads get the chance to
execute the main() method which will cause InterruptedException.
42. Java throws Examples
• // Java program to illustrate throws
• class tst {
• public static void main(String[] args)
• throws InterruptedException
• {
• Thread.sleep(10000);
• System.out.println("Hello Students");
• }
• }
• Output
• Hello Students
• Explanation
• In the above program, by using the throws keyword we handled the InterruptedException and
we will get the output as Hello Geeks
43. Java throws Examples
• // Java program to demonstrate working of throws
• class ThrowsExecp {
• static void fun() throws IllegalAccessException
• {
• System.out.println("Inside fun(). ");
• throw new IllegalAccessException("demo");
• }
• public static void main(String args[])
• {
• try {
• fun();
• }
• catch (IllegalAccessException e) {
• System.out.println("caught in main.");
• }
• }
• }
• Output
• Inside fun(). caught in main.
44. Java throws Keyword
• throws keyword is required only for checked
exceptions and usage of the throws keyword for
unchecked exceptions is meaningless.
• throws keyword is required only to convince the
compiler and usage of the throws keyword does not
prevent abnormal termination of the program.
• With the help of the throws keyword, we can
provide information to the caller of the method
about the exception.
45. Java Custom Exception
• In Java, we can create our own exceptions that
are derived classes of the Exception class.
Creating our own Exception is known as
custom exception or user-defined exception.
• Basically, Java custom exceptions are used to
customize the exception according to user
need.
46. Java Custom Exception
• Consider the example 1 in which
InvalidAgeException class extends the
Exception class.
• Using the custom exception, we can have your
own exception and message. Here, we have
passed a string to the constructor of superclass
i.e. Exception class that can be obtained using
getMessage() method on the object we have
created.
47. Java Custom Exception
• Following are few of the reasons to use custom
exceptions:
• To catch and provide specific treatment to a subset of
existing Java exceptions.
• Business logic exceptions: These are the exceptions
related to business logic and workflow. It is useful for
the application users or the developers to understand
the exact problem.
• In order to create custom exception, we need to extend
Exception class that belongs to java.lang package.
48. Example
• Consider the following example, where we create a
custom exception named WrongFileNameException:
• public class WrongFileNameException extends Exception
• {
• public WrongFileNameException(String errorMessage)
• {
• super(errorMessage);
• }
• }