The document discusses exception handling in Java. It defines exceptions as problems that disrupt normal program flow and defines exception handling as a mechanism to handle runtime errors. It describes different types of exceptions like checked exceptions, unchecked exceptions, and errors. It explains the exception hierarchy and how to use try, catch, and finally blocks to handle exceptions. Finally, it discusses user-defined exceptions, the throw keyword to explicitly throw exceptions, and the throws keyword to declare exceptions.
Data abstraction is the process of hiding certain details and showing only essential information to the user.
Interfaces and Abstract classes.
Contains abstract keyword also.
From this slide you can know about
- Signature
- Polymorphism
-Method
-Types of Method
- Method Overloading
- Sample programme
- Reference Books & websites name
I hope, it is beneficial for beginner Java learner. It's just a simple overview of the topic Method Overloading in Java.
Overview of Spring Boot for the rapid development of Java Applications and Microservices. More information can be found at : https://www.spiraltrain.nl/course-spring-boot-development/?lang=en
Here I discuss about Java programming language and easiest way to solve programming problem. Java basic syntax and their uses are described briefly so that anyone can easily understand within very short time. If anyone follow the slide with proper way,I assure that he or she will find java programming interesting.
Data abstraction is the process of hiding certain details and showing only essential information to the user.
Interfaces and Abstract classes.
Contains abstract keyword also.
From this slide you can know about
- Signature
- Polymorphism
-Method
-Types of Method
- Method Overloading
- Sample programme
- Reference Books & websites name
I hope, it is beneficial for beginner Java learner. It's just a simple overview of the topic Method Overloading in Java.
Overview of Spring Boot for the rapid development of Java Applications and Microservices. More information can be found at : https://www.spiraltrain.nl/course-spring-boot-development/?lang=en
Here I discuss about Java programming language and easiest way to solve programming problem. Java basic syntax and their uses are described briefly so that anyone can easily understand within very short time. If anyone follow the slide with proper way,I assure that he or she will find java programming interesting.
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
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
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.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
2. What is Exception?
• An exception is a problem that arises during the
execution of a program. When an Exception occurs the
normal flow of the program is disrupted and the
program terminates abnormally
• Exception Handling is a mechanism to handle runtime
errors.
3. Situations in which exception
can occur :-
• User entering invalid data.
• Opening a non-existing file.
• Network connections problem.
• Number format exception.
4. Types of Exception
• Checked exceptions − A checked exception is an
exception that occurs at the compile time, these are also
called as Compile time exceptions.
• Unchecked exceptions − An unchecked exception is an
exception that occurs at the time of execution. These are
also called as Runtime Exceptions.
• Errors − These are not exceptions at all, but problems
that arise beyond the control of the user or the
programmer. e.g. OutOfMemoryError,
VirtualMachineError.
6. Try-Catch Block
• Try block- It is used to enclose
the code that might throw an
exception. It must be used within
the method.
• Catch block- It is used to handle
the Exception. It must be used
after the try block only. It involves
declaring the type of exception
you are trying to catch.
Syntax:-
try
{
// Protected code
}
catch(ExceptionName e)
{
// Catch block
}
7. Example (without exception handling)
public class Testtrycatch1{
public static void main(String args[]){
int data=50/0;
System.out.print("rest ");
System.out.print(“of");
System.out.print(“the");
System.out.print(“code");
}
}
Output- Exception in thread main
java.lang.ArithmeticException:/ by zero
8. Example (with exception handling)
public class Testtrycatch2{
public static void main(String args[]){
try{
int data=50/0;
}
catch(ArithmeticException e)
{ System.out.println(e);
}
System.out.println("rest of the code...");
} }
Output- Exception in thread main
java.lang.ArithmeticException:/ by zero
rest of the code...
9. Multiple Catch Block
public class TestMultipleCatchBlock{
public static void main(String args[]){
try{
int a[]=new int[5];
a[5]=30/0;
}
catch(ArithmeticException e){System.out.println(“e");}
catch(ArrayIndexOutOfBoundsException e){System.out.println(“e");}
System.out.println("rest of the code..."); }
}
Output- Exception in thread main
java.lang.ArithmeticException:/ by zero
rest of the code...
10. Some common Sub-Classes of exception
are:-
• ArithmeticException - If we divide any number by
zero, there occurs an ArithmeticException
int a=50/0;
• NullPointerException - If we have null value in any
variable, performing any operation by the variable
occurs an NullPointerException.
String s=null;
System.out.println(s.length());
11. • ArrayIndexOutOfBoundsException - If we are
inserting any value in the wrong index, it would
result ArrayIndexOutOfBoundsException.
int a[]=new int[5];
a[10]=50;
• NumberFormatException- The wrong formatting
of any value, may occur NumberFormatException.
String s="abc";
int i=Integer.parseInt(s);
12. Finally block
• Finally block is a block
that is used to execute
important code.
• It is always executed
whether exception is
handled or not.
• The finally block follows
a try block or a catch
block.
try {
// Protected code
}
catch (ExceptionType1 e1)
{ // Catch block
}
catch (ExceptionType2 e2)
{ // Catch block
}
catch (ExceptionType3 e3)
{ // Catch block
}
finally
{
// The finally block always
executes.
}
13. Example
public class TestFinallyBlock2{
public static void main(String args[]){
try{
int data=25/0;
System.out.println(data); }
catch(ArithmeticException e){
System.out.println(e);}
finally{
System.out.println("finally block will execute");}
} }
Output:Exception in thread main
java.lang.ArithmeticException:/ by zero
finally block will execute
14. User defined exception
• If you are creating your own Exception that is
known as custom exception or user-defined
exception.
• All exceptions must be a child of Throwable.
15. Throw keyword
• Java throw keyword is used to explicitly throw
an exception.
• We can throw either checked or uncheked
exception in java by throw keyword.
• The throw keyword is mainly used to throw user
defined exception.
Syntax:- throw exception;
16. Throws Keyword
• The throws keyword is used to declare an exception.
• It gives an information to the programmer that there
may occur an exception so it is better for the
programmer to provide the exception handling code so
that normal flow can be maintained.
• Syntax:-
return_type method_name() throws exception_class_name{
//method code }
So exception are nothing but some abnormal and typically an event or conditions that arise during the execution which may intrrupt the normal flow of program. and
And many more…
There are mainly two types of exceptions: checked and unchecked where error is considered as unchecked exception.
Checked- These exceptions cannot be ignored at the time of compilation, the programmer should take care of (handle) these exceptions.
Unchecked - These include programming bugs, such as logic errors or improper use of an API. Runtime exceptions are ignored at the time of compilation.
All exception classes are subtypes of the java.lang.Exception class. The exception class and error are the subclasses of the Throwable class.
try block must be followed by either catch or finally block.
You can use multiple catch block with a single try.
In this program we have divide a integer value 50 by 0 and below this there are print messages. When we will execute it a exception ArithmeticException divided by zero will occur and rest of the code will not execute.
Now in this code using try catch block the exception can be handeled. The try clock will throw exception object to catch block and it will handle the exception. An the output will be
A try block can be followed by multiple catch blocks.
We can make multiple catch block . If the data type of the exception thrown matches ExceptionType1, it gets caught there. If not, the exception passes down to the second catch statement.
In this program first exception will occur which is aaruthmatic exceotion. The output will be-
Here are the some sub classes of exception
The finally block follows a try block or a catch block. A finally block of code always executes, irrespective of occurrence of an Exception.
Using a finally block allows you to run any cleanup-type statements that you want to execute, no matter what happens in the protected code.
It means we have to extend the exception class
class InvalidAgeException extends Exception{
InvalidAgeException(String s){
super(s);
}
}
class TestCustomException1{
static void validate(int age)throws InvalidAgeException{
if(age<18)
throw new InvalidAgeException("not valid");
else
System.out.println("welcome to vote");
}
public static void main(String args[]){
try{
validate(13);
}catch(Exception m){System.out.println("Exception occured: "+m);}
System.out.println("rest of the code...");
}
}
import java.lang.Exception;
class MyException extends Exception
{
MyException(String message)
{ super(message);
}
}
class TestMyException
{ output- caught myexception
number is too small
public static void main(String[] args) final block
{
int x = 5, y = 1000;
try {
float z = x / y;
if(z < 0.01)
{ throw new MyException("Number is too small");
}
}
catch(MyException e) {
System.out.println(“caught My Exception”);
System.out.println(e.getMessage());
}
finally {
Number is too small }
System.out.println(“final block");
}}
}