SlideShare a Scribd company logo
Java Exception Handling
&
Applets
Presented By
Tanmoy Roy
1
Roll : 34801216001
Content
 Introduction
 Exception Handling
 Exceptions in Java
 Hierarchy of Java Exception classes
 Types of Exceptions
 Exception Handling Java
 Java Applet
 What is Applet?
 Advantage & Drawback of Applet
 Some Important Points on Java Applet
 Lifecycle of Java Applet
2
Some Interesting Facts about Java
 The initial name of java was “Oak”. it had been modified to Java by Sun’s
marketing department once they found that name was already registered for a
computer company.
 Java is the second preferred language and is incredibly popular among the
developers.
 Java does not support the concept of pointer.
 Java is used by 95% of the companies as their primary language. Which is much
more than C and other languages.
3
Introduction
 The Exception Handling in Java is one amongst the powerful mechanism to
handle the runtime errors so traditional flow of the program will be maintained.
 Applet is a special type of program that is embedded in the webpage to generate
the dynamic content.
4
Exception Handling
5
Exceptions in Java
 An exception is an unwanted or unexpected event, which occurs during the
execution of a program i.e. at run time, that disrupts the normal flow of the
program’s instructions.
6
public class A{
public static void main(String args[])
{
int a=2, b=0, c;
c=a/b; //Exception
System.out.println(c);
}
}
Hierarchy of Java
Exception classes
7
Types of Exceptions
8
The classes which directly inherit Throwable class
except RuntimeException and Error are known as
checked exceptions
The classes which inherit RuntimeException are
known as unchecked exceptions
These are not exceptions at all, but problems that
arise beyond the control of the user or the
programmer.
Types of
Exceptions
9
unchecked exceptions
checked exceptions
Error
Exception Handling Java
10
 Exception Handling mechanism follows a flow which is depicted in the below figure. But if an
exception is not handled, it may lead to a system failure. That is why handling an exception is
very important.
Exception Handling Java
Keyword Description
try The "try" keyword is used to specify a block where we
should place exception code. The try block must be
followed by either catch or finally.
catch The "catch" block is used to handle the exception. It
must be preceded by try block
finally The "finally" block is used to execute the important code
of the program. It is executed whether an exception is
handled or not.
throw The "throw" keyword is used to throw an exception.
throws The "throws" keyword is used to declare exceptions. It
doesn't throw an exception.
11
Exception Handling Java(Example)
package ExceptionHandling;
public class Exception {
public static void main(String args[]) {
try {
int c=100/0;
}catch(ArithmeticException e) {
System.out.println("Exception caught");
}
}
}
12
Java Applet
13
What is Applet?
 An applet is a Java program that runs in a Web browser.
 An applet can be a fully functional Java application because it has the entire Java
API at its disposal.
14
Advantage & Drawback of Applet
 Advantage of Applet
 It works at client side so less response time.
 Secured
 It can be executed by browsers running under many platforms, including Linux,
Windows, Mac OS etc.
 Drawback of Applet
 Plugin is required at client browser to execute applet.
15
Some Important Points on Java Applet
 All applets are sub-classes (either directly or indirectly) of java.applet.Applet
class.
 Applets are not stand-alone programs. Instead, they run within either a web
browser or an applet viewer. JDK provides a standard applet viewer tool called
applet viewer.
 In general, execution of an applet does not begin at main() method.
 Output of an applet window is not performed by System.out.println(). Rather it is
handled with various AWT methods, such as drawString().
16
Lifecycle of Java Applet
17
Lifecycle methods for Applet
18
init( )
destroy( )
start( )
paint( )
stop( )
Lifecycle methods for Applet(Cont.)
19
init( )
destroy( )
start( )
paint( )
stop( )
is used to initialized the Applet. It is invoked only once.
is used to destroy the Applet. It is invoked only once.
is invoked after the init() method or browser is maximized. It is used to start the Applet
is used to paint the Applet. It provides Graphics class object.
is used to stop the Applet. It is invoked when Applet is stop or browser is minimized.
A "Hello, World" Applet
import java.applet.*;
import java.awt.*;
public class HelloWorldApplet extends Applet {
public void paint (Graphics g) {
g.drawString ("Hello World", 25, 50);
}
}
20
<html>
<title>The Hello, World Applet</title>
<hr>
<applet code = "HelloWorldApplet.class"
width = "320" height = "120">
</applet>
<hr>
</html>
HelloWorldApplet.java HelloWorldApplet.html
Conclusion
 Exceptions are used to improve error efficiency.
 The Exception Handling in Java is one of the powerful mechanism to handle
the runtime errors.
 Applet is a Java program that can be embedded into a web page. It runs inside
the web browser and works at client side.
21
References
 Head First Java, 2nd Edition [Book] - O'Reilly Media
 http://javatpoint.com/java-tutorial
 https://www.geeksforgeeks.org/java/
 http://www.programmingtutorials.com/java.aspx
22
Thank You
23

More Related Content

PPTX
Abstract Class & Abstract Method in Core Java
PPT
Java And Multithreading
PPTX
Inner classes in java
PDF
Constructors in Java (2).pdf
PPT
Packages and interfaces
PPTX
Constructor in java
PPTX
This keyword in java
PPTX
Java String
Abstract Class & Abstract Method in Core Java
Java And Multithreading
Inner classes in java
Constructors in Java (2).pdf
Packages and interfaces
Constructor in java
This keyword in java
Java String

What's hot (20)

PPTX
Java exception handling
PPTX
Java abstract class & abstract methods
ODP
OOP java
PPT
Java 8 Streams
PPT
Introduction to method overloading &amp; method overriding in java hdm
PPTX
Multithreading in java
PPTX
Polymorphism presentation in java
PPTX
ArrayList in JAVA
PPTX
CLASS OBJECT AND INHERITANCE IN PYTHON
PPTX
Chapter 07 inheritance
PPSX
Exception Handling
PPTX
Abstraction in java.pptx
PPTX
Spring boot Introduction
PPS
Java Exception handling
PDF
PPT
String classes and its methods.20
PPTX
Inter Thread Communicationn.pptx
PPTX
Abstraction in java
PPTX
Control statements in java
PPT
Exception handling
Java exception handling
Java abstract class & abstract methods
OOP java
Java 8 Streams
Introduction to method overloading &amp; method overriding in java hdm
Multithreading in java
Polymorphism presentation in java
ArrayList in JAVA
CLASS OBJECT AND INHERITANCE IN PYTHON
Chapter 07 inheritance
Exception Handling
Abstraction in java.pptx
Spring boot Introduction
Java Exception handling
String classes and its methods.20
Inter Thread Communicationn.pptx
Abstraction in java
Control statements in java
Exception handling
Ad

Similar to Java Exception Handling and Applets (20)

PDF
JAVA PPT -4 BY ADI.pdf
PPTX
Java/Servlet/JSP/JDBC
PDF
Applet in java
PPT
Java exception
PPTX
UNIT 2.pptx
PPT
Jsp applet
PPTX
using Java Exception Handling in Java.pptx
PDF
JAVA INTRODUCTION
PDF
JAVA INTRODUCTION
PPTX
Exception handling
PPTX
Exception handling in java
PDF
CS3391 -OOP -UNIT – III NOTES FINAL.pdf
PDF
Adv java unit 1 M.Sc CS.pdf
PPTX
OBJECT ORIENTED PROGRAMMING_Unit3_NOTES first half.pptx
PPTX
Exception handling in java
PPTX
Exception handling in java
PPTX
Java programming-Event Handling
PDF
Java exception-handling
PPTX
JAVA UNIT 2
PPT
exception handling in java.ppt
JAVA PPT -4 BY ADI.pdf
Java/Servlet/JSP/JDBC
Applet in java
Java exception
UNIT 2.pptx
Jsp applet
using Java Exception Handling in Java.pptx
JAVA INTRODUCTION
JAVA INTRODUCTION
Exception handling
Exception handling in java
CS3391 -OOP -UNIT – III NOTES FINAL.pdf
Adv java unit 1 M.Sc CS.pdf
OBJECT ORIENTED PROGRAMMING_Unit3_NOTES first half.pptx
Exception handling in java
Exception handling in java
Java programming-Event Handling
Java exception-handling
JAVA UNIT 2
exception handling in java.ppt
Ad

Recently uploaded (20)

PPTX
Spectroscopy.pptx food analysis technology
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
cuic standard and advanced reporting.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Spectroscopy.pptx food analysis technology
Diabetes mellitus diagnosis method based random forest with bat algorithm
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
20250228 LYD VKU AI Blended-Learning.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Programs and apps: productivity, graphics, security and other tools
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Chapter 3 Spatial Domain Image Processing.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
NewMind AI Weekly Chronicles - August'25 Week I
Spectral efficient network and resource selection model in 5G networks
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
The Rise and Fall of 3GPP – Time for a Sabbatical?
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
cuic standard and advanced reporting.pdf
Digital-Transformation-Roadmap-for-Companies.pptx

Java Exception Handling and Applets

  • 1. Java Exception Handling & Applets Presented By Tanmoy Roy 1 Roll : 34801216001
  • 2. Content  Introduction  Exception Handling  Exceptions in Java  Hierarchy of Java Exception classes  Types of Exceptions  Exception Handling Java  Java Applet  What is Applet?  Advantage & Drawback of Applet  Some Important Points on Java Applet  Lifecycle of Java Applet 2
  • 3. Some Interesting Facts about Java  The initial name of java was “Oak”. it had been modified to Java by Sun’s marketing department once they found that name was already registered for a computer company.  Java is the second preferred language and is incredibly popular among the developers.  Java does not support the concept of pointer.  Java is used by 95% of the companies as their primary language. Which is much more than C and other languages. 3
  • 4. Introduction  The Exception Handling in Java is one amongst the powerful mechanism to handle the runtime errors so traditional flow of the program will be maintained.  Applet is a special type of program that is embedded in the webpage to generate the dynamic content. 4
  • 6. Exceptions in Java  An exception is an unwanted or unexpected event, which occurs during the execution of a program i.e. at run time, that disrupts the normal flow of the program’s instructions. 6 public class A{ public static void main(String args[]) { int a=2, b=0, c; c=a/b; //Exception System.out.println(c); } }
  • 8. Types of Exceptions 8 The classes which directly inherit Throwable class except RuntimeException and Error are known as checked exceptions The classes which inherit RuntimeException are known as unchecked exceptions These are not exceptions at all, but problems that arise beyond the control of the user or the programmer.
  • 10. Exception Handling Java 10  Exception Handling mechanism follows a flow which is depicted in the below figure. But if an exception is not handled, it may lead to a system failure. That is why handling an exception is very important.
  • 11. Exception Handling Java Keyword Description try The "try" keyword is used to specify a block where we should place exception code. The try block must be followed by either catch or finally. catch The "catch" block is used to handle the exception. It must be preceded by try block finally The "finally" block is used to execute the important code of the program. It is executed whether an exception is handled or not. throw The "throw" keyword is used to throw an exception. throws The "throws" keyword is used to declare exceptions. It doesn't throw an exception. 11
  • 12. Exception Handling Java(Example) package ExceptionHandling; public class Exception { public static void main(String args[]) { try { int c=100/0; }catch(ArithmeticException e) { System.out.println("Exception caught"); } } } 12
  • 14. What is Applet?  An applet is a Java program that runs in a Web browser.  An applet can be a fully functional Java application because it has the entire Java API at its disposal. 14
  • 15. Advantage & Drawback of Applet  Advantage of Applet  It works at client side so less response time.  Secured  It can be executed by browsers running under many platforms, including Linux, Windows, Mac OS etc.  Drawback of Applet  Plugin is required at client browser to execute applet. 15
  • 16. Some Important Points on Java Applet  All applets are sub-classes (either directly or indirectly) of java.applet.Applet class.  Applets are not stand-alone programs. Instead, they run within either a web browser or an applet viewer. JDK provides a standard applet viewer tool called applet viewer.  In general, execution of an applet does not begin at main() method.  Output of an applet window is not performed by System.out.println(). Rather it is handled with various AWT methods, such as drawString(). 16
  • 17. Lifecycle of Java Applet 17
  • 18. Lifecycle methods for Applet 18 init( ) destroy( ) start( ) paint( ) stop( )
  • 19. Lifecycle methods for Applet(Cont.) 19 init( ) destroy( ) start( ) paint( ) stop( ) is used to initialized the Applet. It is invoked only once. is used to destroy the Applet. It is invoked only once. is invoked after the init() method or browser is maximized. It is used to start the Applet is used to paint the Applet. It provides Graphics class object. is used to stop the Applet. It is invoked when Applet is stop or browser is minimized.
  • 20. A "Hello, World" Applet import java.applet.*; import java.awt.*; public class HelloWorldApplet extends Applet { public void paint (Graphics g) { g.drawString ("Hello World", 25, 50); } } 20 <html> <title>The Hello, World Applet</title> <hr> <applet code = "HelloWorldApplet.class" width = "320" height = "120"> </applet> <hr> </html> HelloWorldApplet.java HelloWorldApplet.html
  • 21. Conclusion  Exceptions are used to improve error efficiency.  The Exception Handling in Java is one of the powerful mechanism to handle the runtime errors.  Applet is a Java program that can be embedded into a web page. It runs inside the web browser and works at client side. 21
  • 22. References  Head First Java, 2nd Edition [Book] - O'Reilly Media  http://javatpoint.com/java-tutorial  https://www.geeksforgeeks.org/java/  http://www.programmingtutorials.com/java.aspx 22