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

PDF
NOSQL- Presentation on NoSQL
PPSX
Java annotations
PPTX
Java program structure
DOCX
Exceptions handling notes in JAVA
PDF
JavaScript - Chapter 12 - Document Object Model
PPT
Java Notes
PPTX
Database Access With JDBC
PPS
Java Exception handling
NOSQL- Presentation on NoSQL
Java annotations
Java program structure
Exceptions handling notes in JAVA
JavaScript - Chapter 12 - Document Object Model
Java Notes
Database Access With JDBC
Java Exception handling

What's hot (20)

PPT
Database backup and recovery basics
PDF
DBMS Unit - 6 - Transaction Management
PPTX
Event Handling in java
PPT
Jsp ppt
PPTX
Operators in java
PDF
Java Thread Synchronization
PPT
Method overriding
PPTX
Features of JAVA Programming Language.
PPTX
Basics of JAVA programming
PPTX
Association agggregation and composition
PPTX
interface in c#
PPTX
Java Decision Control
PPTX
Java.util
PPTX
Java History
PPTX
Namespaces in C#
DOCX
Basic java important interview questions and answers to secure a job
PPTX
JAVA AWT
PPTX
I/O Streams
PPTX
Interface in java
PPTX
Deadlock dbms
Database backup and recovery basics
DBMS Unit - 6 - Transaction Management
Event Handling in java
Jsp ppt
Operators in java
Java Thread Synchronization
Method overriding
Features of JAVA Programming Language.
Basics of JAVA programming
Association agggregation and composition
interface in c#
Java Decision Control
Java.util
Java History
Namespaces in C#
Basic java important interview questions and answers to secure a job
JAVA AWT
I/O Streams
Interface in java
Deadlock dbms
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
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Sensors and Actuators in IoT Systems using pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Cloud computing and distributed systems.
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Modernizing your data center with Dell and AMD
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Empathic Computing: Creating Shared Understanding
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
GamePlan Trading System Review: Professional Trader's Honest Take
20250228 LYD VKU AI Blended-Learning.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Sensors and Actuators in IoT Systems using pdf
Review of recent advances in non-invasive hemoglobin estimation
Cloud computing and distributed systems.
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Understanding_Digital_Forensics_Presentation.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Advanced methodologies resolving dimensionality complications for autism neur...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Modernizing your data center with Dell and AMD
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Empathic Computing: Creating Shared Understanding
Advanced Soft Computing BINUS July 2025.pdf
Spectral efficient network and resource selection model in 5G networks
The Rise and Fall of 3GPP – Time for a Sabbatical?
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.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