SlideShare a Scribd company logo
JAVA 
BASIC TERMS TO BE KNOWN…..
Facts and history 
Who invented java? 
James Gosling 
Where? 
Sun lab also known as sun micro 
system. 
When? 
Around 1992, published in 1995. 
What is first name at a time of invention? 
“oak”, from the name of tree outside 
the window of James.
Facts and history 
Why the name “java” and the symbol a “coffee cup”? 
Some issues with the name “oak”. 
Seating in the local café. 
Wounded up with the name “java”. 
From the cup of coffee. 
What is the relation with c/c++? 
Java was created as a successor to C++ in order 
to address various problems of that language
Features of java 
Compiled and interpreted 
 Source code  byte code and byte code  machine code 
 Platform independent and portable 
 Can be run on any platform 
 Secure 
 Ensures that no virus is communicated with applet 
 Distributed 
 Multiple programmers at different remote locations can collaborate and work together 
 High performance 
 Faster execution speed 
 Multi language supported 
Dynamic and extensible 
New class library, classes and methods can be linked dynamically
JIT, Jvm, jre and jdk 
 JIT 
 Just-In-Time 
 Component of JRE 
 Improves the performance 
 JVM 
 Provides runtime environment in which java byte 
code is executed. 
 Compilation + interpretation 
 Not physically present 
 JRE 
 Runtime environment 
 Implementation of JVM 
 Contains a libraries + other files 
 JDK 
 JRE + development tools 
 Bundle of softwares
Different versions 
 JDK 1.0 (January 21, 1996) 
 JDK 1.1 (February 19, 1997) 
 J2SE 1.2 (December 8, 1998) 
 J2SE 1.3 (May 8, 2000) 
 J2SE 1.4 (February 6, 2002) 
 J2SE 5.0 (September 30, 2004) 
 Java SE 6 (December 11, 2006) 
 Java SE 7 (July 28, 2011) 
 Java SE 8 (March 18, 2014)
Advantages over c/c++ 
 Improved software maintainability 
 Faster development 
 Lower cost of development 
 Higher quality software 
 Use of notepad makes it easier 
 Supports method overloading and overriding 
 Errors can be handled with the use of Exception 
 Automatic garbage collection
STARTING THE BASICS… 
File name: Abc.java 
Code: 
class abc 
{ 
public static void main(String args[]) 
{ 
System.out.print("hello, how are you all??"); 
} 
}
Meaning of each term 
Public: visibility mode 
Static: to use without creating object 
Void: return type 
String: pre-defined class 
Args: array name 
System: pre-defined class 
Out: object 
Print: method 
Make sure: 
 No need of saving file with initial capital 
letter 
 File name can be saved with the different 
name of class name
String to integer and double 
class conv 
{ 
public static void main(String a[]) 
{ 
int a; 
String b="1921"; 
double c; 
a=Integer.parseInt(b); 
System.out.println(a); 
c=Double.parseDouble(b); 
System.out.println(c); 
} 
}
Final variable 
Value that will be constant through out the program. 
 Can not assign another value. 
 Study following program. 
class fin 
{ 
public static void main(String a[]) 
{ 
final int a=9974; 
System.out.print(a); 
a=759; 
System.out.print(a); 
} 
}
Errors and exception 
What is the difference??? 
Errors 
Something that make a program go wrong. 
 Can give unexpected result. 
Types: 
Compile-time errors 
 Run-time errors 
Exception 
 Condition that is caused by a run-rime error in the program. 
 Ex. Dividing by zero. 
 Interpreter creates an exception object and throws it.
errors 
Compile-time Error 
 Occurs at the time of compilation. 
 Syntax errors 
 Detected and displayed by the interpreter. 
 .class file will not be created 
 For successful compilation it need to be fixed. 
 For ex. Missing semicolon or missing brackets.
More examples 
 Misspelling of identifier or keyword 
 Missing double quotes in string 
 Use of undeclared variable 
 Use of = in place of == operator 
 Path not found 
Changing the value of variable which is declared final
errors 
Run-time Error 
 Program compile successfully 
 Class file also generated. 
 Though may not run successfully 
 Or may produce wrong o/p due to wrong logic 
 Error message generated 
 Program aborted 
 For ex. Divide by zero.
More examples 
 Accessing an element that is out of bound of an array. 
Trying to store a value into an array of an incompatible class or type. 
 Passing a parameter that is not in a valid range. 
 Attempting to use a negative size for an array. 
 Converting invalid string to a number 
 Accessing a character that is out of bound of a string.
class Err 
{ 
public static void main(String bdnfs[]) 
{ 
int a=50,b=10,c=10; 
int result=a/(b-c); 
System.out.print(result); 
int res=a/(b+c); 
System.out.print(res); 
} 
} 
WHICH ONE IS THIS??
exception 
 Caused by run-time error in the program. 
 If it is not caught and handled properly, the interpreter will display an error message. 
 Ex. ArithmeticException 
ArrayIndexOutOfBoundException 
FileNotFoundException 
OutOfMemoryExcepion 
SecurityException 
StackOverFlowException
Exception HANDLING 
 In previous program , if we want to continue the execution with the remaining 
code, then we should try to catch the exception object thrown by error condition 
and then display an appropriate message for taking correct actions. 
 This task Is known as Exception Handling. 
 The purpose of this is to provide a means to detect and report circumstances. 
 So appropriate action can be taken 
 It contains 4 sub tasks. 
 Find the problem(Hit) 
 Inform that error has occurred(Throw) 
 Receive the error Information(Catch) 
Take corrective action(Handle)
Syntax 
…………………………. 
…………………………. 
Try 
{ 
statements; // generates an Exception 
} 
Catch (Exception-type e) 
{ 
statements; // processes the Exception 
} 
……………………….... 
…………………………
example 
class Err2 
{ 
public static void main(String bdnfs[]) 
{ 
int a=50,b=10,c=10; 
int result,res; 
try 
{ 
result=a/(b-c); 
} 
catch (ArithmeticException e) 
{ 
System.out.println("can not divided by zero "); 
} 
res=a/(b+c); 
System.out.print(res); 
} 
}
Multiple catch statements 
…………………………. 
…………………………. 
Try 
{ 
statements; // generates an Exception 
} 
Catch (Exception-type-1 e) 
{ 
statements; // processes the Exception type 1 
} 
Catch (Exception-type-2 e) 
{ 
statements; // processes the Exception type 2 
} 
. 
. 
. 
. 
Catch (Exception-type-N e) 
{ 
statements; // processes the Exception type N 
} 
……………………….... 
…………………………
Finally statement 
 Finally statement is supported by Java to handle a type of exception 
that is not handled by catch statement. 
 It may be immediately added after try block or after the last catch 
block. 
 Guaranteed to execute whether the exception Is thrown or not. 
 Can be used for performing certain house-keeping operation such a 
closing files and realizing system resources. 
 Syntax for using finally statement is shown in next slide.
Syntax 
Try 
{ 
………….. 
………….. 
} 
Catch (……….) 
{ 
………….. 
………….. 
} 
Finally 
{ 
………….. 
………….. 
} 
Decide according to 
program that 
whether to use catch 
block or not…
class Err3 
{ 
public static void main(String bdnfs[]) 
{ 
int a[]={50,100}; 
int x=5; 
try 
{ 
int p=a[2]/(x-a[0]); 
} 
finally 
{ 
int q=a[1]/a[0]; 
System.out.println(q); 
} 
} 
} 
example
Some puzzles.. 
String mesg = “Answer is “; int sum = 1 + 2; System.out.println(mesg + sum); 
 Output: “Answer is 3” 
int sum = 5; sum = sum + sum *5/2; System.out.println(sum); 
 Output: 17 
int limit = 25; int count = 30; int total = 200; count *=5; limit -=5; total +=count 
+ limit; System.out.println("total =" + total); 
 Output: 370 
String str1 = "Java"; String str2 = "Java program"; String str3 = "program"; 
char c = ' '; String s1 = str1 + str3; String s2 = str1 + "c"; String s3 = str1 + c; 
String s4 = “ “; s4 += str1; String s5 = s4 + str3; 
 Output: “Javac”
References 
 http://darwinsys.com/java/javaTopTen.html 
 http://www.funtrivia.com/en/subtopics/javao-programming-204270.html 
 http://cs-fundamentals.com/java-programming/difference-between-jdk-jre-jvm-jit. 
php 
 http://www.javabeat.net/what-is-the-difference-between-jrejvm-and-jdk/ 
 http://www.fixoncloud.com/Home/LoginValidate/OneProblemComplete_Detailed.p 
hp?problemid=535
Prepred by: 
Saurabh Prajapati(11ce21)

More Related Content

What's hot (20)

PPT
Introduction to JavaScript
Andres Baravalle
 
PPT
Debugging
Indu Sharma Bhardwaj
 
PPT
System Models in Software Engineering SE7
koolkampus
 
PPT
android activity
Deepa Rani
 
PPT
Entity Relationship Diagram
Shakila Mahjabin
 
PDF
Object-Oriented Analysis And Design With Applications Grady Booch
Sorina Chirilă
 
PPSX
Collections - Maps
Hitesh-Java
 
PPT
Abstract class in java
Lovely Professional University
 
PDF
Android activities & views
ma-polimi
 
PPS
Java Exception handling
kamal kotecha
 
PPT
ADO .Net
DrSonali Vyas
 
PPTX
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
PPTX
Java architecture
Rakesh
 
PPTX
Chapter-7 Relational Calculus
Kunal Anand
 
PPTX
Formal Approaches to SQA.pptx
KarthigaiSelviS3
 
PPT
15. Transactions in DBMS
koolkampus
 
PPTX
L14 exception handling
teach4uin
 
PPTX
Planning the development process
Siva Priya
 
PPTX
Interface in java
PhD Research Scholar
 
PPTX
Transaction states and properties
Chetan Mahawar
 
Introduction to JavaScript
Andres Baravalle
 
System Models in Software Engineering SE7
koolkampus
 
android activity
Deepa Rani
 
Entity Relationship Diagram
Shakila Mahjabin
 
Object-Oriented Analysis And Design With Applications Grady Booch
Sorina Chirilă
 
Collections - Maps
Hitesh-Java
 
Abstract class in java
Lovely Professional University
 
Android activities & views
ma-polimi
 
Java Exception handling
kamal kotecha
 
ADO .Net
DrSonali Vyas
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Java architecture
Rakesh
 
Chapter-7 Relational Calculus
Kunal Anand
 
Formal Approaches to SQA.pptx
KarthigaiSelviS3
 
15. Transactions in DBMS
koolkampus
 
L14 exception handling
teach4uin
 
Planning the development process
Siva Priya
 
Interface in java
PhD Research Scholar
 
Transaction states and properties
Chetan Mahawar
 

Viewers also liked (20)

PDF
History of java
Mani Sarkar
 
PDF
History of Java 1/2
Eberhard Wolff
 
PPT
Evolution Of Java
Munish Gupta
 
PPTX
Turing machine-TOC
Maulik Togadiya
 
PPT
Ip sec
shifanabasheer
 
PPTX
remote sensor
SAurabh PRajapati
 
PPTX
Data mining
Maulik Togadiya
 
PDF
6. The grid-COMPUTING OGSA and WSRF
Dr Sandeep Kumar Poonia
 
PPTX
Distributed file system
Anamika Singh
 
PDF
Distributed Operating System_2
Dr Sandeep Kumar Poonia
 
PPTX
Ccleaner presentation
SAurabh PRajapati
 
PDF
Lecture28 tsp
Dr Sandeep Kumar Poonia
 
PPT
Multiple Access in wireless communication
Maulik Togadiya
 
PPTX
optimization of DFA
Maulik Togadiya
 
PPTX
Distributed shred memory architecture
Maulik Togadiya
 
PDF
Distributed computing
Deepak John
 
PPTX
IDS n IPS
SAurabh PRajapati
 
PDF
Soft computing
Dr Sandeep Kumar Poonia
 
PPT
Light emitting Diode
SAurabh PRajapati
 
History of java
Mani Sarkar
 
History of Java 1/2
Eberhard Wolff
 
Evolution Of Java
Munish Gupta
 
Turing machine-TOC
Maulik Togadiya
 
remote sensor
SAurabh PRajapati
 
Data mining
Maulik Togadiya
 
6. The grid-COMPUTING OGSA and WSRF
Dr Sandeep Kumar Poonia
 
Distributed file system
Anamika Singh
 
Distributed Operating System_2
Dr Sandeep Kumar Poonia
 
Ccleaner presentation
SAurabh PRajapati
 
Multiple Access in wireless communication
Maulik Togadiya
 
optimization of DFA
Maulik Togadiya
 
Distributed shred memory architecture
Maulik Togadiya
 
Distributed computing
Deepak John
 
Soft computing
Dr Sandeep Kumar Poonia
 
Light emitting Diode
SAurabh PRajapati
 
Ad

Similar to Java history, versions, types of errors and exception, quiz (20)

PPT
Exceptions in java
Rajkattamuri
 
PPTX
Javasession4
Rajeev Kumar
 
PPT
Exception Handling Exception Handling Exception Handling
AboMohammad10
 
PDF
Adv java unit 1 M.Sc CS.pdf
KALAISELVI P
 
PDF
Ch-1_5.pdf this is java tutorials for all
HayomeTakele
 
PPT
Exception handling in java
AmbigaMurugesan
 
PPTX
UNIT III 2021R.pptx
RDeepa9
 
PPTX
UNIT III 2021R.pptx
RDeepa9
 
PPT
exception handling in java.ppt
Varshini62
 
PPT
exceptions in java
javeed_mhd
 
PPT
Exceptions in java
Manav Prasad
 
PPTX
Interface andexceptions
saman Iftikhar
 
PPTX
Exception handling
Ardhendu Nandi
 
PPTX
Exception handling in java
Kavitha713564
 
PPT
Java exception
Arati Gadgil
 
PPTX
Chap2 exception handling
raksharao
 
PPTX
Java-Unit 3- Chap2 exception handling
raksharao
 
PPT
Comp102 lec 10
Fraz Bakhsh
 
PPTX
Exceptions handling in java
junnubabu
 
PPTX
UNIT 2.pptx
EduclentMegasoftel
 
Exceptions in java
Rajkattamuri
 
Javasession4
Rajeev Kumar
 
Exception Handling Exception Handling Exception Handling
AboMohammad10
 
Adv java unit 1 M.Sc CS.pdf
KALAISELVI P
 
Ch-1_5.pdf this is java tutorials for all
HayomeTakele
 
Exception handling in java
AmbigaMurugesan
 
UNIT III 2021R.pptx
RDeepa9
 
UNIT III 2021R.pptx
RDeepa9
 
exception handling in java.ppt
Varshini62
 
exceptions in java
javeed_mhd
 
Exceptions in java
Manav Prasad
 
Interface andexceptions
saman Iftikhar
 
Exception handling
Ardhendu Nandi
 
Exception handling in java
Kavitha713564
 
Java exception
Arati Gadgil
 
Chap2 exception handling
raksharao
 
Java-Unit 3- Chap2 exception handling
raksharao
 
Comp102 lec 10
Fraz Bakhsh
 
Exceptions handling in java
junnubabu
 
UNIT 2.pptx
EduclentMegasoftel
 
Ad

Recently uploaded (20)

PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
Controller Request and Response in Odoo18
Celine George
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 

Java history, versions, types of errors and exception, quiz

  • 1. JAVA BASIC TERMS TO BE KNOWN…..
  • 2. Facts and history Who invented java? James Gosling Where? Sun lab also known as sun micro system. When? Around 1992, published in 1995. What is first name at a time of invention? “oak”, from the name of tree outside the window of James.
  • 3. Facts and history Why the name “java” and the symbol a “coffee cup”? Some issues with the name “oak”. Seating in the local café. Wounded up with the name “java”. From the cup of coffee. What is the relation with c/c++? Java was created as a successor to C++ in order to address various problems of that language
  • 4. Features of java Compiled and interpreted  Source code  byte code and byte code  machine code  Platform independent and portable  Can be run on any platform  Secure  Ensures that no virus is communicated with applet  Distributed  Multiple programmers at different remote locations can collaborate and work together  High performance  Faster execution speed  Multi language supported Dynamic and extensible New class library, classes and methods can be linked dynamically
  • 5. JIT, Jvm, jre and jdk  JIT  Just-In-Time  Component of JRE  Improves the performance  JVM  Provides runtime environment in which java byte code is executed.  Compilation + interpretation  Not physically present  JRE  Runtime environment  Implementation of JVM  Contains a libraries + other files  JDK  JRE + development tools  Bundle of softwares
  • 6. Different versions  JDK 1.0 (January 21, 1996)  JDK 1.1 (February 19, 1997)  J2SE 1.2 (December 8, 1998)  J2SE 1.3 (May 8, 2000)  J2SE 1.4 (February 6, 2002)  J2SE 5.0 (September 30, 2004)  Java SE 6 (December 11, 2006)  Java SE 7 (July 28, 2011)  Java SE 8 (March 18, 2014)
  • 7. Advantages over c/c++  Improved software maintainability  Faster development  Lower cost of development  Higher quality software  Use of notepad makes it easier  Supports method overloading and overriding  Errors can be handled with the use of Exception  Automatic garbage collection
  • 8. STARTING THE BASICS… File name: Abc.java Code: class abc { public static void main(String args[]) { System.out.print("hello, how are you all??"); } }
  • 9. Meaning of each term Public: visibility mode Static: to use without creating object Void: return type String: pre-defined class Args: array name System: pre-defined class Out: object Print: method Make sure:  No need of saving file with initial capital letter  File name can be saved with the different name of class name
  • 10. String to integer and double class conv { public static void main(String a[]) { int a; String b="1921"; double c; a=Integer.parseInt(b); System.out.println(a); c=Double.parseDouble(b); System.out.println(c); } }
  • 11. Final variable Value that will be constant through out the program.  Can not assign another value.  Study following program. class fin { public static void main(String a[]) { final int a=9974; System.out.print(a); a=759; System.out.print(a); } }
  • 12. Errors and exception What is the difference??? Errors Something that make a program go wrong.  Can give unexpected result. Types: Compile-time errors  Run-time errors Exception  Condition that is caused by a run-rime error in the program.  Ex. Dividing by zero.  Interpreter creates an exception object and throws it.
  • 13. errors Compile-time Error  Occurs at the time of compilation.  Syntax errors  Detected and displayed by the interpreter.  .class file will not be created  For successful compilation it need to be fixed.  For ex. Missing semicolon or missing brackets.
  • 14. More examples  Misspelling of identifier or keyword  Missing double quotes in string  Use of undeclared variable  Use of = in place of == operator  Path not found Changing the value of variable which is declared final
  • 15. errors Run-time Error  Program compile successfully  Class file also generated.  Though may not run successfully  Or may produce wrong o/p due to wrong logic  Error message generated  Program aborted  For ex. Divide by zero.
  • 16. More examples  Accessing an element that is out of bound of an array. Trying to store a value into an array of an incompatible class or type.  Passing a parameter that is not in a valid range.  Attempting to use a negative size for an array.  Converting invalid string to a number  Accessing a character that is out of bound of a string.
  • 17. class Err { public static void main(String bdnfs[]) { int a=50,b=10,c=10; int result=a/(b-c); System.out.print(result); int res=a/(b+c); System.out.print(res); } } WHICH ONE IS THIS??
  • 18. exception  Caused by run-time error in the program.  If it is not caught and handled properly, the interpreter will display an error message.  Ex. ArithmeticException ArrayIndexOutOfBoundException FileNotFoundException OutOfMemoryExcepion SecurityException StackOverFlowException
  • 19. Exception HANDLING  In previous program , if we want to continue the execution with the remaining code, then we should try to catch the exception object thrown by error condition and then display an appropriate message for taking correct actions.  This task Is known as Exception Handling.  The purpose of this is to provide a means to detect and report circumstances.  So appropriate action can be taken  It contains 4 sub tasks.  Find the problem(Hit)  Inform that error has occurred(Throw)  Receive the error Information(Catch) Take corrective action(Handle)
  • 20. Syntax …………………………. …………………………. Try { statements; // generates an Exception } Catch (Exception-type e) { statements; // processes the Exception } ……………………….... …………………………
  • 21. example class Err2 { public static void main(String bdnfs[]) { int a=50,b=10,c=10; int result,res; try { result=a/(b-c); } catch (ArithmeticException e) { System.out.println("can not divided by zero "); } res=a/(b+c); System.out.print(res); } }
  • 22. Multiple catch statements …………………………. …………………………. Try { statements; // generates an Exception } Catch (Exception-type-1 e) { statements; // processes the Exception type 1 } Catch (Exception-type-2 e) { statements; // processes the Exception type 2 } . . . . Catch (Exception-type-N e) { statements; // processes the Exception type N } ……………………….... …………………………
  • 23. Finally statement  Finally statement is supported by Java to handle a type of exception that is not handled by catch statement.  It may be immediately added after try block or after the last catch block.  Guaranteed to execute whether the exception Is thrown or not.  Can be used for performing certain house-keeping operation such a closing files and realizing system resources.  Syntax for using finally statement is shown in next slide.
  • 24. Syntax Try { ………….. ………….. } Catch (……….) { ………….. ………….. } Finally { ………….. ………….. } Decide according to program that whether to use catch block or not…
  • 25. class Err3 { public static void main(String bdnfs[]) { int a[]={50,100}; int x=5; try { int p=a[2]/(x-a[0]); } finally { int q=a[1]/a[0]; System.out.println(q); } } } example
  • 26. Some puzzles.. String mesg = “Answer is “; int sum = 1 + 2; System.out.println(mesg + sum);  Output: “Answer is 3” int sum = 5; sum = sum + sum *5/2; System.out.println(sum);  Output: 17 int limit = 25; int count = 30; int total = 200; count *=5; limit -=5; total +=count + limit; System.out.println("total =" + total);  Output: 370 String str1 = "Java"; String str2 = "Java program"; String str3 = "program"; char c = ' '; String s1 = str1 + str3; String s2 = str1 + "c"; String s3 = str1 + c; String s4 = “ “; s4 += str1; String s5 = s4 + str3;  Output: “Javac”
  • 27. References  http://darwinsys.com/java/javaTopTen.html  http://www.funtrivia.com/en/subtopics/javao-programming-204270.html  http://cs-fundamentals.com/java-programming/difference-between-jdk-jre-jvm-jit. php  http://www.javabeat.net/what-is-the-difference-between-jrejvm-and-jdk/  http://www.fixoncloud.com/Home/LoginValidate/OneProblemComplete_Detailed.p hp?problemid=535
  • 28. Prepred by: Saurabh Prajapati(11ce21)

Editor's Notes

  • #9: Ask that will the program give me output?? Then explain that its not necessary of saving the programs with same name as class.
  • #10: Another visibility modes, return type, array name can b anything, another objects, methods