SlideShare a Scribd company logo
Java Virtual Machine
(JVM)
By:
Prof. Ansari Aadil S.
1
Prof. Aadil Ansari
Basic Introduction to JVM
• Java Virtual Machine is a set of software & program
components. As name suggests, it is a virtual computer
that resides within real computer.
• Java can achieve platform independent feature due to
JVM.
• When we want to write java program, we write the
source code into notepad & store it in the file having
extension .java
Prof. Aadil Ansari
Continue..
• The .java file is compiled using javac compiler. On
compilation a .class file gets generated. This class file is
actually a byte code.
• JVM takes byte code as an input, reads it, interprets it &
then execute it.
• JVM can generate output corresponding to the
underlying operating system.
Prof. Aadil Ansari
JVM act as an Mediator between OS & Java
Text Editor
Java Source
Code
javac
Byte code(.class File)
Windows Mac Linux
Run using java
Compile using javac
Java Virtual
Machine
Prof. Aadil Ansari
Prof. Aadil Ansari
Data types
Prof. Aadil Ansari
Prof. Aadil Ansari
Prof. Aadil Ansari
• System.out.print(“Hello”);
• System.out.print(“n”);
• System.out.print(“Java!”);
print( )method //print and wait
println( )method //print a line and move to the next line
• System.out.println(“Hello”);
• System.out.println(“Java!”);
Prof. Aadil Ansari
Classes
• A class is a collection of fields (data) and methods
(procedure or function) that operate on that data.
• The basic syntax for a class definition:
• For Example:-
class Rectangle {
// my Rectangle class
}
class classname [extends SuperClassName]
{
[fields declaration]
[methods declaration]
}
Prof. Aadil Ansari
Adding Variables: Class Rectangle with fields
• Add variables
• The fields (data) are also called the instance variables.
class Rectangle
{
int length; // Data fields OR instance Variables
float width;
}
Prof. Aadil Ansari
Adding Methods
• Methods are declared inside the body of the
class but immediately after the declaration of
instance variable.
• The general form of a method declaration is:
type methodname (parameter-list)
{
Method-body;
}
Prof. Aadil Ansari
Adding Methods to Class Rectangle
class Rectangle
{
int length;
float width;
void getData(int x, float y) //Method declaration
{
length =x;
width= y;
}
}
Method Body
Prof. Aadil Ansari
Constructor
• Constructor is a special method with same name
as it’s class name
• No return type for constructor. Not even void
• Constructors are implicitly called when objects
are created
• A constructor without input parameter is default
constructor
• Constructor can be overloaded
Prof. Aadil Ansari
class Student4
• {
int id;
String name;
Student4(int i,String n) //constructor
{
id = i;
name = n;
}
void display()
{
System.out.println(id+" "+name);
}
public static void main(String args[])
{
Student4 s1 = new Student4(111,"Karan");
Student4 s2 = new Student4(222,"Aryan");
s1.display();
s2.display();
}Prof. Aadil Ansari
• Output:
111 Karan 222 Aryan
Prof. Aadil Ansari
Creating objects of a class
• Objects in java are created using new operator.
• The new operator creates an object of specified class &
returns a reference of that object.
• For Example:- Rectangle rect1;
rect1 = new Rectangle();
Prof. Aadil Ansari
Continue..
 Both the statement can be combined into one as shown
below.
Rectangle rect1 = new Rectangle();
 The method Rectangle() is default constructor of class.
We can create any number of objects of Rectangle class.
Rectangle rect1 = new Rectangle();
Rectangle rect2 = new Rectangle();
Prof. Aadil Ansari
Prof. Aadil Ansari
Exception handling & Error
• Signal occurs when some unusual condition occurs.
• Various types of signals are Exceptions, Errors,
Interrupts & Controls.
• Exception:- Appropriate execution is raised when some
unusual condition occurs.
• Errors:- Compile time error.
Prof. Aadil Ansari
Continue
• Exception Handling:-The statements that are
likely to cause an exception are enclosed within
a try block.
• There is another block defined by keyword
catch which responsible for handling the
exception thrown by the try block.
• The catch is added immediately after the try
block.
Prof. Aadil Ansari
General syntax of try & catch
try
{
// exception get generated here.
}
catch(Type_of_Exception e)
{
// exception is handled here
}
Prof. Aadil Ansari
For Example:-
class RunErrDemo
{
public static void main(String arg[])
{
int a,b,c;
a= 10, b=0;
try
{
c = a/b; //Exception occurs because the element is
divided by 0
}
Prof. Aadil Ansari
Program continue..
catch(ArithmeticException e)
{
System.out.println(“You cannot divide by Zero”);
}
System.out.println(“ The value of a:” +a);
System.out.println(“The value of b:”+b);
}
}
Prof. Aadil Ansari
Output for above program is
You cannot divide by Zero
The value of a: 10
The value of b: 0
Prof. Aadil Ansari
• Any Questions???????
Prof. Aadil Ansari
• Thank You
Prof. Aadil Ansari

More Related Content

What's hot (20)

Java Tutorial Lab 4
Java Tutorial Lab 4Java Tutorial Lab 4
Java Tutorial Lab 4
Berk Soysal
 
Java8 features
Java8 featuresJava8 features
Java8 features
Minal Maniar
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference Card
Hari kiran G
 
Framework Design Guidelines
Framework Design GuidelinesFramework Design Guidelines
Framework Design Guidelines
Mohamed Meligy
 
Advanced c#
Advanced c#Advanced c#
Advanced c#
AkashThakrar
 
The Ring programming language version 1.5.1 book - Part 68 of 180
The Ring programming language version 1.5.1 book - Part 68 of 180The Ring programming language version 1.5.1 book - Part 68 of 180
The Ring programming language version 1.5.1 book - Part 68 of 180
Mahmoud Samir Fayed
 
C++
C++C++
C++
vrushali shivsharan
 
2CPP04 - Objects and Classes
2CPP04 - Objects and Classes2CPP04 - Objects and Classes
2CPP04 - Objects and Classes
Michael Heron
 
Basics of java (1)
Basics of java (1)Basics of java (1)
Basics of java (1)
raj upadhyay
 
Java Introduction Workshop Day 2
Java Introduction Workshop Day 2 Java Introduction Workshop Day 2
Java Introduction Workshop Day 2
Osama Saad
 
Exception handling
Exception handlingException handling
Exception handling
Minal Maniar
 
QSpiders - Major difference
QSpiders - Major differenceQSpiders - Major difference
QSpiders - Major difference
Qspiders - Software Testing Training Institute
 
Introduction to c first week slides
Introduction to c first week slidesIntroduction to c first week slides
Introduction to c first week slides
luqman bawany
 
Abstract classes & interfaces
Abstract classes & interfacesAbstract classes & interfaces
Abstract classes & interfaces
moazamali28
 
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building BlocksOCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
İbrahim Kürce
 
Beginning Java for .NET developers
Beginning Java for .NET developersBeginning Java for .NET developers
Beginning Java for .NET developers
Andrei Rinea
 
C++ - Constructors,Destructors, Operator overloading and Type conversion
C++ - Constructors,Destructors, Operator overloading and Type conversionC++ - Constructors,Destructors, Operator overloading and Type conversion
C++ - Constructors,Destructors, Operator overloading and Type conversion
Hashni T
 
Logic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing ApplicationsLogic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing Applications
kjkleindorfer
 
Constructors
ConstructorsConstructors
Constructors
Puneet tiwari
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statements
İbrahim Kürce
 
Java Tutorial Lab 4
Java Tutorial Lab 4Java Tutorial Lab 4
Java Tutorial Lab 4
Berk Soysal
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference Card
Hari kiran G
 
Framework Design Guidelines
Framework Design GuidelinesFramework Design Guidelines
Framework Design Guidelines
Mohamed Meligy
 
The Ring programming language version 1.5.1 book - Part 68 of 180
The Ring programming language version 1.5.1 book - Part 68 of 180The Ring programming language version 1.5.1 book - Part 68 of 180
The Ring programming language version 1.5.1 book - Part 68 of 180
Mahmoud Samir Fayed
 
2CPP04 - Objects and Classes
2CPP04 - Objects and Classes2CPP04 - Objects and Classes
2CPP04 - Objects and Classes
Michael Heron
 
Basics of java (1)
Basics of java (1)Basics of java (1)
Basics of java (1)
raj upadhyay
 
Java Introduction Workshop Day 2
Java Introduction Workshop Day 2 Java Introduction Workshop Day 2
Java Introduction Workshop Day 2
Osama Saad
 
Exception handling
Exception handlingException handling
Exception handling
Minal Maniar
 
Introduction to c first week slides
Introduction to c first week slidesIntroduction to c first week slides
Introduction to c first week slides
luqman bawany
 
Abstract classes & interfaces
Abstract classes & interfacesAbstract classes & interfaces
Abstract classes & interfaces
moazamali28
 
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building BlocksOCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
İbrahim Kürce
 
Beginning Java for .NET developers
Beginning Java for .NET developersBeginning Java for .NET developers
Beginning Java for .NET developers
Andrei Rinea
 
C++ - Constructors,Destructors, Operator overloading and Type conversion
C++ - Constructors,Destructors, Operator overloading and Type conversionC++ - Constructors,Destructors, Operator overloading and Type conversion
C++ - Constructors,Destructors, Operator overloading and Type conversion
Hashni T
 
Logic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing ApplicationsLogic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing Applications
kjkleindorfer
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statements
İbrahim Kürce
 

Similar to JAVA VIRTUAL MACHINE (20)

#_ varible function
#_ varible function #_ varible function
#_ varible function
abdullah al mahamud rosi
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
Partnered Health
 
Java
JavaJava
Java
Zeeshan Khan
 
Module 1.pptx
Module 1.pptxModule 1.pptx
Module 1.pptx
YakaviBalakrishnan
 
Core Java Concepts
Core Java ConceptsCore Java Concepts
Core Java Concepts
mdfkhan625
 
PROGRAMMING IN JAVA
PROGRAMMING IN JAVAPROGRAMMING IN JAVA
PROGRAMMING IN JAVA
SivaSankari36
 
Oops
OopsOops
Oops
Gayathri Ganesh
 
Java
JavaJava
Java
nirbhayverma8
 
JAVA PROGRAMMING presentation for engineering student.pptx
JAVA PROGRAMMING presentation for engineering student.pptxJAVA PROGRAMMING presentation for engineering student.pptx
JAVA PROGRAMMING presentation for engineering student.pptx
proboygamer007
 
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
KALAISELVI P
 
Core java
Core javaCore java
Core java
Shivaraj R
 
Core java
Core javaCore java
Core java
Sun Technlogies
 
Java 102 intro to object-oriented programming in java
Java 102   intro to object-oriented programming in javaJava 102   intro to object-oriented programming in java
Java 102 intro to object-oriented programming in java
agorolabs
 
Java Tutorial
Java Tutorial Java Tutorial
Java Tutorial
Akash Pandey
 
Exception Handling Exception Handling Exception Handling
Exception Handling Exception Handling Exception HandlingException Handling Exception Handling Exception Handling
Exception Handling Exception Handling Exception Handling
AboMohammad10
 
Control structures functions and modules in python programming
Control structures functions and modules in python programmingControl structures functions and modules in python programming
Control structures functions and modules in python programming
Srinivas Narasegouda
 
Class introduction in java
Class introduction in javaClass introduction in java
Class introduction in java
yugandhar vadlamudi
 
class as the basis.pptx
class as the basis.pptxclass as the basis.pptx
class as the basis.pptx
Epsiba1
 
core java
core javacore java
core java
Vinodh Kumar
 
Quick Interview Preparation for C# All Concepts
Quick Interview Preparation for C# All ConceptsQuick Interview Preparation for C# All Concepts
Quick Interview Preparation for C# All Concepts
Karmanjay Verma
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
Partnered Health
 
Core Java Concepts
Core Java ConceptsCore Java Concepts
Core Java Concepts
mdfkhan625
 
JAVA PROGRAMMING presentation for engineering student.pptx
JAVA PROGRAMMING presentation for engineering student.pptxJAVA PROGRAMMING presentation for engineering student.pptx
JAVA PROGRAMMING presentation for engineering student.pptx
proboygamer007
 
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
KALAISELVI P
 
Java 102 intro to object-oriented programming in java
Java 102   intro to object-oriented programming in javaJava 102   intro to object-oriented programming in java
Java 102 intro to object-oriented programming in java
agorolabs
 
Exception Handling Exception Handling Exception Handling
Exception Handling Exception Handling Exception HandlingException Handling Exception Handling Exception Handling
Exception Handling Exception Handling Exception Handling
AboMohammad10
 
Control structures functions and modules in python programming
Control structures functions and modules in python programmingControl structures functions and modules in python programming
Control structures functions and modules in python programming
Srinivas Narasegouda
 
class as the basis.pptx
class as the basis.pptxclass as the basis.pptx
class as the basis.pptx
Epsiba1
 
Quick Interview Preparation for C# All Concepts
Quick Interview Preparation for C# All ConceptsQuick Interview Preparation for C# All Concepts
Quick Interview Preparation for C# All Concepts
Karmanjay Verma
 

Recently uploaded (20)

Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
Generative AI & Large Language Models Agents
Generative AI & Large Language Models AgentsGenerative AI & Large Language Models Agents
Generative AI & Large Language Models Agents
aasgharbee22seecs
 
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
 
introduction technology technology tec.pptx
introduction technology technology tec.pptxintroduction technology technology tec.pptx
introduction technology technology tec.pptx
Iftikhar70
 
Uses of drones in civil construction.pdf
Uses of drones in civil construction.pdfUses of drones in civil construction.pdf
Uses of drones in civil construction.pdf
surajsen1729
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjjseninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
AjijahamadKhaji
 
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink DisplayHow to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
CircuitDigest
 
Evonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdfEvonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdf
szhang13
 
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
Guru Nanak Technical Institutions
 
Modeling the Influence of Environmental Factors on Concrete Evaporation Rate
Modeling the Influence of Environmental Factors on Concrete Evaporation RateModeling the Influence of Environmental Factors on Concrete Evaporation Rate
Modeling the Influence of Environmental Factors on Concrete Evaporation Rate
Journal of Soft Computing in Civil Engineering
 
Design of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdfDesign of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdf
Kamel Farid
 
Nanometer Metal-Organic-Framework Literature Comparison
Nanometer Metal-Organic-Framework  Literature ComparisonNanometer Metal-Organic-Framework  Literature Comparison
Nanometer Metal-Organic-Framework Literature Comparison
Chris Harding
 
hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .
NABLAS株式会社
 
Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
Generative AI & Large Language Models Agents
Generative AI & Large Language Models AgentsGenerative AI & Large Language Models Agents
Generative AI & Large Language Models Agents
aasgharbee22seecs
 
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
 
introduction technology technology tec.pptx
introduction technology technology tec.pptxintroduction technology technology tec.pptx
introduction technology technology tec.pptx
Iftikhar70
 
Uses of drones in civil construction.pdf
Uses of drones in civil construction.pdfUses of drones in civil construction.pdf
Uses of drones in civil construction.pdf
surajsen1729
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjjseninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
AjijahamadKhaji
 
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink DisplayHow to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
CircuitDigest
 
Evonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdfEvonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdf
szhang13
 
Design of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdfDesign of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdf
Kamel Farid
 
Nanometer Metal-Organic-Framework Literature Comparison
Nanometer Metal-Organic-Framework  Literature ComparisonNanometer Metal-Organic-Framework  Literature Comparison
Nanometer Metal-Organic-Framework Literature Comparison
Chris Harding
 
hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .
NABLAS株式会社
 

JAVA VIRTUAL MACHINE

  • 1. Java Virtual Machine (JVM) By: Prof. Ansari Aadil S. 1 Prof. Aadil Ansari
  • 2. Basic Introduction to JVM • Java Virtual Machine is a set of software & program components. As name suggests, it is a virtual computer that resides within real computer. • Java can achieve platform independent feature due to JVM. • When we want to write java program, we write the source code into notepad & store it in the file having extension .java Prof. Aadil Ansari
  • 3. Continue.. • The .java file is compiled using javac compiler. On compilation a .class file gets generated. This class file is actually a byte code. • JVM takes byte code as an input, reads it, interprets it & then execute it. • JVM can generate output corresponding to the underlying operating system. Prof. Aadil Ansari
  • 4. JVM act as an Mediator between OS & Java Text Editor Java Source Code javac Byte code(.class File) Windows Mac Linux Run using java Compile using javac Java Virtual Machine Prof. Aadil Ansari
  • 9. • System.out.print(“Hello”); • System.out.print(“n”); • System.out.print(“Java!”); print( )method //print and wait println( )method //print a line and move to the next line • System.out.println(“Hello”); • System.out.println(“Java!”); Prof. Aadil Ansari
  • 10. Classes • A class is a collection of fields (data) and methods (procedure or function) that operate on that data. • The basic syntax for a class definition: • For Example:- class Rectangle { // my Rectangle class } class classname [extends SuperClassName] { [fields declaration] [methods declaration] } Prof. Aadil Ansari
  • 11. Adding Variables: Class Rectangle with fields • Add variables • The fields (data) are also called the instance variables. class Rectangle { int length; // Data fields OR instance Variables float width; } Prof. Aadil Ansari
  • 12. Adding Methods • Methods are declared inside the body of the class but immediately after the declaration of instance variable. • The general form of a method declaration is: type methodname (parameter-list) { Method-body; } Prof. Aadil Ansari
  • 13. Adding Methods to Class Rectangle class Rectangle { int length; float width; void getData(int x, float y) //Method declaration { length =x; width= y; } } Method Body Prof. Aadil Ansari
  • 14. Constructor • Constructor is a special method with same name as it’s class name • No return type for constructor. Not even void • Constructors are implicitly called when objects are created • A constructor without input parameter is default constructor • Constructor can be overloaded Prof. Aadil Ansari
  • 15. class Student4 • { int id; String name; Student4(int i,String n) //constructor { id = i; name = n; } void display() { System.out.println(id+" "+name); } public static void main(String args[]) { Student4 s1 = new Student4(111,"Karan"); Student4 s2 = new Student4(222,"Aryan"); s1.display(); s2.display(); }Prof. Aadil Ansari
  • 16. • Output: 111 Karan 222 Aryan Prof. Aadil Ansari
  • 17. Creating objects of a class • Objects in java are created using new operator. • The new operator creates an object of specified class & returns a reference of that object. • For Example:- Rectangle rect1; rect1 = new Rectangle(); Prof. Aadil Ansari
  • 18. Continue..  Both the statement can be combined into one as shown below. Rectangle rect1 = new Rectangle();  The method Rectangle() is default constructor of class. We can create any number of objects of Rectangle class. Rectangle rect1 = new Rectangle(); Rectangle rect2 = new Rectangle(); Prof. Aadil Ansari
  • 20. Exception handling & Error • Signal occurs when some unusual condition occurs. • Various types of signals are Exceptions, Errors, Interrupts & Controls. • Exception:- Appropriate execution is raised when some unusual condition occurs. • Errors:- Compile time error. Prof. Aadil Ansari
  • 21. Continue • Exception Handling:-The statements that are likely to cause an exception are enclosed within a try block. • There is another block defined by keyword catch which responsible for handling the exception thrown by the try block. • The catch is added immediately after the try block. Prof. Aadil Ansari
  • 22. General syntax of try & catch try { // exception get generated here. } catch(Type_of_Exception e) { // exception is handled here } Prof. Aadil Ansari
  • 23. For Example:- class RunErrDemo { public static void main(String arg[]) { int a,b,c; a= 10, b=0; try { c = a/b; //Exception occurs because the element is divided by 0 } Prof. Aadil Ansari
  • 24. Program continue.. catch(ArithmeticException e) { System.out.println(“You cannot divide by Zero”); } System.out.println(“ The value of a:” +a); System.out.println(“The value of b:”+b); } } Prof. Aadil Ansari
  • 25. Output for above program is You cannot divide by Zero The value of a: 10 The value of b: 0 Prof. Aadil Ansari
  • 27. • Thank You Prof. Aadil Ansari
  翻译: