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

What's hot

Exception handling
Exception handlingException handling
Exception handling
PhD Research Scholar
 
Exception handling in Java
Exception handling in JavaException handling in Java
Exception handling in Java
Ankit Rai
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
pooja kumari
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
SURIT DATTA
 
Java exception handling
Java exception handlingJava exception handling
Java exception handlingBHUVIJAYAVELU
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
Pratik Soares
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
Md. Tanvir Hossain
 
Java string handling
Java string handlingJava string handling
Java string handling
Salman Khan
 
Java-java virtual machine
Java-java virtual machineJava-java virtual machine
Java-java virtual machine
Surbhi Panhalkar
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
Java2Blog
 
Exception handling
Exception handlingException handling
Exception handling
Tata Consultancy Services
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
lalithambiga kamaraj
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
VINOTH R
 
Exception Handling In Java
Exception Handling In JavaException Handling In Java
Exception Handling In Java
parag
 
Files in java
Files in javaFiles in java
Exception Handling in C#
Exception Handling in C#Exception Handling in C#
Exception Handling in C#
Abid Kohistani
 
Exception handling in java
Exception handling  in javaException handling  in java

What's hot (20)

Exception handling
Exception handlingException handling
Exception handling
 
Exception handling in Java
Exception handling in JavaException handling in Java
Exception handling in Java
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
Java string handling
Java string handlingJava string handling
Java string handling
 
Java-java virtual machine
Java-java virtual machineJava-java virtual machine
Java-java virtual machine
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
Exception handling
Exception handlingException handling
Exception handling
 
Exception handling in Java
Exception handling in JavaException handling in Java
Exception handling in Java
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
OOP java
OOP javaOOP java
OOP java
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
Exception Handling In Java
Exception Handling In JavaException Handling In Java
Exception Handling In Java
 
C# Delegates
C# DelegatesC# Delegates
C# Delegates
 
Files in java
Files in javaFiles in java
Files in java
 
Exception Handling in C#
Exception Handling in C#Exception Handling in C#
Exception Handling in C#
 
Exception handling in java
Exception handling  in javaException handling  in java
Exception handling in java
 

Similar to Java Exception Handling and Applets

Itp 120 Chapt 18 2009 Exceptions & Assertions
Itp 120 Chapt 18 2009 Exceptions & AssertionsItp 120 Chapt 18 2009 Exceptions & Assertions
Itp 120 Chapt 18 2009 Exceptions & Assertionsphanleson
 
Applet1 (1).pptx
Applet1 (1).pptxApplet1 (1).pptx
Applet1 (1).pptx
FahanaAbdulVahab
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
AmbigaMurugesan
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
RamaPrabha24
 
UNIT-3.pptx Exception Handling and Multithreading
UNIT-3.pptx Exception Handling and MultithreadingUNIT-3.pptx Exception Handling and Multithreading
UNIT-3.pptx Exception Handling and Multithreading
SakkaravarthiS1
 
Applet
AppletApplet
Applet
pooja kumari
 
Exception Handling Multithreading: Fundamental of Exception; Exception types;...
Exception Handling Multithreading: Fundamental of Exception; Exception types;...Exception Handling Multithreading: Fundamental of Exception; Exception types;...
Exception Handling Multithreading: Fundamental of Exception; Exception types;...
poongothai11
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
ARAFAT ISLAM
 
B.Sc. III(VI Sem) Advance Java Unit1: Exception Handling & Multithreading
B.Sc. III(VI Sem) Advance Java Unit1: Exception Handling & MultithreadingB.Sc. III(VI Sem) Advance Java Unit1: Exception Handling & Multithreading
B.Sc. III(VI Sem) Advance Java Unit1: Exception Handling & Multithreading
Assistant Professor, Shri Shivaji Science College, Amravati
 
Java Applets
Java AppletsJava Applets
Java Applets
Mohamed Essam
 
Exception Handling.pptx
Exception Handling.pptxException Handling.pptx
Exception Handling.pptx
primevideos176
 
Java applet
Java appletJava applet
Java applet
Elizabeth alexander
 
Applet
 Applet Applet
Applet
swapnac12
 
Java programming-Event Handling
Java programming-Event HandlingJava programming-Event Handling
Java programming-Event HandlingJava Programming
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
Class notes(week 8) on exception handling
Class notes(week 8) on exception handlingClass notes(week 8) on exception handling
Class notes(week 8) on exception handling
Kuntal Bhowmick
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
Gary Mendonca
 
Exception handling
Exception handlingException handling
Exception handling
Ardhendu Nandi
 

Similar to Java Exception Handling and Applets (20)

Itp 120 Chapt 18 2009 Exceptions & Assertions
Itp 120 Chapt 18 2009 Exceptions & AssertionsItp 120 Chapt 18 2009 Exceptions & Assertions
Itp 120 Chapt 18 2009 Exceptions & Assertions
 
Applet1 (1).pptx
Applet1 (1).pptxApplet1 (1).pptx
Applet1 (1).pptx
 
APPLET.pptx
APPLET.pptxAPPLET.pptx
APPLET.pptx
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
 
UNIT-3.pptx Exception Handling and Multithreading
UNIT-3.pptx Exception Handling and MultithreadingUNIT-3.pptx Exception Handling and Multithreading
UNIT-3.pptx Exception Handling and Multithreading
 
Applet
AppletApplet
Applet
 
Exception Handling Multithreading: Fundamental of Exception; Exception types;...
Exception Handling Multithreading: Fundamental of Exception; Exception types;...Exception Handling Multithreading: Fundamental of Exception; Exception types;...
Exception Handling Multithreading: Fundamental of Exception; Exception types;...
 
UNIT 2.pptx
UNIT 2.pptxUNIT 2.pptx
UNIT 2.pptx
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
B.Sc. III(VI Sem) Advance Java Unit1: Exception Handling & Multithreading
B.Sc. III(VI Sem) Advance Java Unit1: Exception Handling & MultithreadingB.Sc. III(VI Sem) Advance Java Unit1: Exception Handling & Multithreading
B.Sc. III(VI Sem) Advance Java Unit1: Exception Handling & Multithreading
 
Java Applets
Java AppletsJava Applets
Java Applets
 
Exception Handling.pptx
Exception Handling.pptxException Handling.pptx
Exception Handling.pptx
 
Java applet
Java appletJava applet
Java applet
 
Applet
 Applet Applet
Applet
 
Java programming-Event Handling
Java programming-Event HandlingJava programming-Event Handling
Java programming-Event Handling
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
 
Class notes(week 8) on exception handling
Class notes(week 8) on exception handlingClass notes(week 8) on exception handling
Class notes(week 8) on exception handling
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
 
Exception handling
Exception handlingException handling
Exception handling
 

Recently uploaded

Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 

Recently uploaded (20)

Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 

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