Java Programming Day 1
Java Programming Day 1
PROGRAMMING
Faculty: BIRENDRA KUMAR SINGH
Session Agenda
• Object Oriented Programming vs Procedural Programming
• Differences between C++ & Java Programming Language
• Introduction to Java
• History of Java
• Features of Java
• JDK, JRE, JVM
• Building blocks of Java Program
Session Agenda
• JVM Architecture
• Building Blocks of Java Program
• Variables and Datatypes
• Input from user
• Operators in Java
OBJECT ORIENTED VS PROCEDURAL
PROGRAMMING
Object Oriented Programming vs Procedural
Programming
• Procedural Programming can be defined as a programming model which is
derived from structured programming, based upon the concept of calling procedure.
• Procedures, also known as routines, subroutines or functions, simply consist of a
series of computational steps to be carried out. During a program’s execution, any
given procedure might be called at any point, including by other procedures or
itself.
• Languages used in Procedural Programming:
• FORTRAN, ALGOL, COBOL, BASIC, Pascal and C.
Object Oriented Programming vs Procedural
Programming
• Object oriented programming can be defined as a programming model
which is based upon the concept of objects.
• Objects contain data in the form of attributes and code in the form of
methods.
• In object oriented programming, computer programs are designed using
the concept of objects that interact with real world.
Object Oriented Programming vs Procedural
Programming
Procedural Oriented Programming Object Oriented Programming
In procedural programming, program is divided In object oriented programming, program is
into small parts called functions. divided into small parts called objects.
Procedural programming does not have any proper Object oriented programming provides data hiding
way for hiding data so it is less secure. so it is more secure.
Object Oriented Programming vs
Procedural Programming
Procedural Oriented Programming Object Oriented Programming
Examples: C, FORTRAN, Pascal, Basic etc. Examples: C++, Java, Python, C# etc.
Support for programming Allows both procedural programming and object- Support object-oriented
type oriented programming. programming model.
Source file
Application
Programmin Class file
g Interface
JVM
Java Architecture
The source code of a Java application is saved in a source file with
the extension, .java.
JVM is responsible for executing the bytecode and generating the
machine specific code for the machine on which the Java program
needs to be executed.
The Java API is a collection of software components, such as
classes, interfaces, and methods.
Java Architecture (Contd.)
JVM ARCHITECTURE
JVM Architecture
JVM Architecture(Contd.)
• Class Loader : Used to load class files
• Bootstrap ClassLoader: Loads rt.jar file which contains all class files
present in Java Packages
• Extension ClassLoader: Child classloader of Bootstrap class loader.
It loads the jar files located inside $JAVA_HOME/jre/lib/ext
directory
• System/Application Classloader: Child classloader of Extension
classloader.
• Loads the class files from classpath.
JVM Architecture(Contd.)
• Class(Method) Area: Stores per-class structure such as fields, method data and
code for methods
• Heap: Runtime data area in which objects are allocated.
• Stack: It store frames. It stores local variables and plays important role in
method invocation and return.
• Each time a new frame is created when a method is invoked and get destroyed when
method invocation completes’
• Program Counter Register: Contains the address of JVM instructions
executing currently.
JVM Architecture(Contd.)
• Native Method Stack: Contains all the native methods used in application. A native method is a Java
method (either an instance method or a class method) whose implementation is also written in another
programming language such as C/C++.
• Execution engine: It contains :-
• A virtual processor
• Interpretor: It is responsible for reading and executing the program. It is designed in such a way that it can read the
source program and translate the source code instruction by instruction.
• JIT compiler: JIT compiles parts of the byte code that have similar functionality at the same time, and hence
reduces the amount of time needed for compilation. It is a translator from the instruction set of a Java virtual machine
(JVM) to the instruction set of a specific CPU.
• Java Native Interface
• Provides an interface to communicate with another application written in another language like C, C++, Assembly etc.
JAVA PROGRAM COMPONENTS
PREREQUISITE
Packages
Classes
Main Method
THANK YOU