SlideShare une entreprise Scribd logo
1  sur  28
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)

Contenu connexe

Tendances (20)

Java Collections
Java  Collections Java  Collections
Java Collections
 
Introduction to class in java
Introduction to class in javaIntroduction to class in java
Introduction to class in java
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
 
Java IO
Java IOJava IO
Java IO
 
jQuery
jQueryjQuery
jQuery
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 
Introduction to Java 8
Introduction to Java 8Introduction to Java 8
Introduction to Java 8
 
Java swing
Java swingJava swing
Java swing
 
Event handling
Event handlingEvent handling
Event handling
 
Notification android
Notification androidNotification android
Notification android
 
QSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and JitQSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and Jit
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
Delegates and events in C#
Delegates and events in C#Delegates and events in C#
Delegates and events in C#
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Java servlets
Java servletsJava servlets
Java servlets
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Remote Method Invocation (RMI)
Remote Method Invocation (RMI)
 
String in java
String in javaString in java
String in java
 

En vedette (20)

History of java
History of javaHistory of java
History of java
 
History of Java 1/2
History of Java 1/2History of Java 1/2
History of Java 1/2
 
Evolution Of Java
Evolution Of JavaEvolution Of Java
Evolution Of Java
 
Turing machine-TOC
Turing machine-TOCTuring machine-TOC
Turing machine-TOC
 
Ip sec
Ip secIp sec
Ip sec
 
remote sensor
remote sensorremote sensor
remote sensor
 
Data mining
Data miningData mining
Data mining
 
12. dfs
12. dfs12. dfs
12. dfs
 
6. The grid-COMPUTING OGSA and WSRF
6. The grid-COMPUTING OGSA and WSRF6. The grid-COMPUTING OGSA and WSRF
6. The grid-COMPUTING OGSA and WSRF
 
Distributed file system
Distributed file systemDistributed file system
Distributed file system
 
Distributed Operating System_2
Distributed Operating System_2Distributed Operating System_2
Distributed Operating System_2
 
Ccleaner presentation
Ccleaner presentationCcleaner presentation
Ccleaner presentation
 
Lecture28 tsp
Lecture28 tspLecture28 tsp
Lecture28 tsp
 
Multiple Access in wireless communication
Multiple Access in wireless communicationMultiple Access in wireless communication
Multiple Access in wireless communication
 
optimization of DFA
optimization of DFAoptimization of DFA
optimization of DFA
 
Distributed shred memory architecture
Distributed shred memory architectureDistributed shred memory architecture
Distributed shred memory architecture
 
Distributed computing
Distributed computingDistributed computing
Distributed computing
 
IDS n IPS
IDS n IPSIDS n IPS
IDS n IPS
 
Soft computing
Soft computingSoft computing
Soft computing
 
Light emitting Diode
Light emitting DiodeLight emitting Diode
Light emitting Diode
 

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

Java programming basics
Java programming basicsJava programming basics
Java programming basicsHamid Ghorbani
 
CLR Exception Handing And Memory Management
CLR Exception Handing And Memory ManagementCLR Exception Handing And Memory Management
CLR Exception Handing And Memory ManagementShiny Zhu
 
Introduction
IntroductionIntroduction
Introductionrichsoden
 
Exceptions overview
Exceptions overviewExceptions overview
Exceptions overviewBharath K
 
Java -Exception handlingunit-iv
Java -Exception handlingunit-ivJava -Exception handlingunit-iv
Java -Exception handlingunit-ivRubaNagarajan
 
java basic for begginers
java basic for begginersjava basic for begginers
java basic for begginersdivaskrgupta007
 
Adv java unit 1 M.Sc CS.pdf
Adv java unit 1 M.Sc CS.pdfAdv java unit 1 M.Sc CS.pdf
Adv java unit 1 M.Sc CS.pdfKALAISELVI P
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010Rich Helton
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satyaSatya Johnny
 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objectsvmadan89
 
01-ch01-1-println.ppt java introduction one
01-ch01-1-println.ppt java introduction one01-ch01-1-println.ppt java introduction one
01-ch01-1-println.ppt java introduction onessuser656672
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1sotlsoc
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller ColumnsJonathan Fine
 

Similaire à Java history, versions, types of errors and exception, quiz (20)

Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
CLR Exception Handing And Memory Management
CLR Exception Handing And Memory ManagementCLR Exception Handing And Memory Management
CLR Exception Handing And Memory Management
 
Introduction
IntroductionIntroduction
Introduction
 
Javascript
JavascriptJavascript
Javascript
 
Java cheat sheet
Java cheat sheet Java cheat sheet
Java cheat sheet
 
Java: Exception
Java: ExceptionJava: Exception
Java: Exception
 
Exceptions overview
Exceptions overviewExceptions overview
Exceptions overview
 
java intro.pptx.pdf
java intro.pptx.pdfjava intro.pptx.pdf
java intro.pptx.pdf
 
Java -Exception handlingunit-iv
Java -Exception handlingunit-ivJava -Exception handlingunit-iv
Java -Exception handlingunit-iv
 
java basic for begginers
java basic for begginersjava basic for begginers
java basic for begginers
 
Adv java unit 1 M.Sc CS.pdf
Adv java unit 1 M.Sc CS.pdfAdv java unit 1 M.Sc CS.pdf
Adv java unit 1 M.Sc CS.pdf
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010
 
Adv kvr -satya
Adv  kvr -satyaAdv  kvr -satya
Adv kvr -satya
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satya
 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objects
 
01-ch01-1-println.ppt java introduction one
01-ch01-1-println.ppt java introduction one01-ch01-1-println.ppt java introduction one
01-ch01-1-println.ppt java introduction one
 
Java
JavaJava
Java
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
Java platform
Java platformJava platform
Java platform
 

Dernier

Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 

Dernier (20)

Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 

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)

Notes de l'éditeur

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