Java is an object-oriented programming language that is high-level, robust, secure, portable and multi-threaded. It was developed by James Gosling at Sun Microsystems in the early 1990s. Java code is compiled into bytecode that runs on a Java Virtual Machine (JVM) making Java platform independent. The JVM interprets the bytecode and performs tasks like memory management and security.
2. Java Language
Java is High level, Object Oriented Programming
Language
• Object Oriented – Follows OOP methodologies
• Java developed by James Gosling and colleagues
at Sun Microsystems in the early 1990s.
• The acquisition of Sun Microsystems by Oracle
Corporation was completed on January 27,
2010
www.infoviaan.com
2
3. Programming Language
Programming Language -
• A programming language is a formal language,
which comprises a set of instructions used to
produce various kinds of output.
• Programming languages are used to create
programs or software that implement specific
algorithms.
• The term programming language usually refers
to high-level languages, such as C, C++, Java,
Python etc.
www.infoviaan.com
3
4. High Level Language
High Level Programming language –
• A high-level language that enables development
of a program in a much more user-friendly
programming context and is generally
independent of the computer's hardware
architecture.
www.infoviaan.com
4
5. Java Version History
1997 JAVA 1.1
2004 JAVA 5
2011 JAVA 7
No Major Changes
between 1.1 to 1.4
Major Changes in 1.5
No Major Changes in Java 6
Major Changes in Java 7
PureOOP
2014 JAVA 8
2017 JAVA 9
2018 JAVA 10
Major Changes
Major
Changes
Major Changes
OOP+Functional
5
www.infoviaan.com
6. OOP VS Functional Prog.
OOP
• Its based on the concept of
"objects", which may contain
data, in the form of fields,
often known as attributes.
• It’s code, in the form of
procedures, often known as
methods.
• Class, Object, Encapsulation,
Inheritance, Polymorphism,
Abstraction etc. are the
concepts of OOP.
• Ex. Java, Ruby etc.
FP
• Its try to bind everything
in pure mathematical
functions style.
• It is a declarative type
of programming style
• Its main focus is on “what
to solve” in contrast to an
imperative style where the
main focus is “how to
solve”
• Functions, recursion etc.
are concept of FP
• Ex. C, PHP etc. 6
www.infoviaan.com
8. 1. Object Oriented
• Employee in IT company works on multiple Technologies,
communicates with each other, works on 2 projects parallel,
holds various responsibilities and perform actions/work as per
their assigned role.
CEO, CTO , CIO , Manager, Team Leader, Developer, Tester,
Designer etc.
• Object Oriented -
• Java follows OOP methodologies.
• Focus on the data hold/ associated by objects and methods
for manipulating the data.
IT
Company
CIO Manager Team
8
www.infoviaan.com
9. Object
• Object is represents any real world entity
• Object actually exists in memory
• Objects have states and behaviours.
Example: A dog has states - colour, name, breed as well as
behaviours – wagging the tail, barking, eating.
• Which have own memory
• It is Instance of the class
University Principal Classroom Computer Lab
9
www.infoviaan.com
10. Object has state and behavior
Object has state and behavior
State - state are stored in memory variable
- state will be changed by behavior
Behavior- behavior perform operation
- behavior are implemented by function, and
function are called method in OOP.
States/variables
Colour: white
Gear: 2nd
Speed: 40
Behaviour/method
changeColor()
changeGear()
accelerator()
break()
Object
10
www.infoviaan.com
11. Structure of an object
Before any object creation you have to create structure or
design.
• Structure means template or blueprint of an object.
• Class is the structure or skeleton or design of an object.
• State and behavior of an object are defined by Class.
• Object is the instance/memory of the class.
State / Member Variable/ Attribute
Function / Method / Member
method
Class
11
www.infoviaan.com
12. Class vs Object
Hall
WashroomBed Room
Bed Room
Wash
basin
path Gate
Kitchen
Plot – Map (blueprint)
Class
Constructed – Object 1
Constructed – Object 2
State/Attributes :
door
window
color
Behaviour/Method:
changeColor()
changeDoor()
openWindow()
…
Washroom
Washroom
12
www.infoviaan.com
13. 2. Simple
• Java is easy to write and more readable.
• Java has a concise, cohesive set of features that
makes it easy to learn it easy to learn and use.
• No pointers
• Automatic garbage collection (memory
management).
• Java was designed to make it much easier to write
bug free code.
• Java is an excellent teaching language, and an
excellent choice with which to learn programming.
The language is small so it's easy to become fluent.
13
www.infoviaan.com
14. 3. Secured
Java is secured because:
• No explicit pointer
• Java programs run inside virtual machine sandbox
C/C++ application
Operating System
Uses runtime
Environment of its own
Java Virtual Machine
Uses runtime environment Of OS
Java application
Operating System
Uses runtime environment Of OS
14
www.infoviaan.com
18. C, C++
Windows Linux Mac OS
.C .obj/
machine code
Windows Linux
.C machine
code
Mac OS
Development
Machine
Run
Machine
.C
machine code
18
www.infoviaan.com
19. Class File
Windows Linux Mac OS
Windows
JavaDevelopment
Machine
RunMachine
Windows
JVM/Setup
Linux
JVM/Setup
Mac/OS
JVM/Setup
19
www.infoviaan.com
21. 5. Robust
Robust means strong. Java program are strong
and they don’t crash easily like c and c++.
• Excellent exception handling
• Memory management
• Class loader sub system of JVM will allocate
necessary memory for java program.
• Garbage collector de allocates the memory.
21
www.infoviaan.com
22. 6. Portable
• Java is considered as Portable because – Output of a Java
compiler is Non Executable Code i.e Bytecode. Bytecode is
executed by Java run-time system, which is called the Java
Virtual Machine (JVM).
• They can run on any platform without being re compiled.
• Being architectural-neutral and having no implementation
dependent aspect of the specification makes java portable.
Machine 1 - Window Machine 2 - Linux
Connected with LANHello.class Hello O/P
22
www.infoviaan.com
23. 7. Architectural-neutral
• Write once, run anywhere (WORA)
• With a JVM, you can write one program that
will run on any platform.
• Java compiler generates an architectural-neutral
object file format, which makes the compiled
code executable on many processors, with the
presence of Java Runtime System.
• Means java byte code is architectural-neutral .
23
www.infoviaan.com
24. 8. Dynamic
• Java is dynamic because, java bytecode(.class file) is
interpreted by JVM.
• Static means, java source code (.java file) is
compiled into another language(byte code) before it
is executed – it is not directly executable.
• So , we might say that java byte code is dynamic.
• Java has Dynamic and Extensible Code Means With
the Help of OOPS java Provides Inheritance and
With the Help of Inheritance we Reuse the Code
that is Pre-defined and Also uses all the built in
Functions of java and Classes
24
www.infoviaan.com
25. 9. Compile & Interpreted
Compiler –
• Convert complete source code
at a time of a program.
• Fast Processing.
• Worked Before run of
program
Converting
source
code to byte
code
in one shot
Converting
source
code to byte
code
line by line
JAVAC JIT
Interpreter –
• Convert source code Line
by line of a program.
• Slow Processing.
• Worked after run of
program
25
www.infoviaan.com
26. 10. High Performance
• Java performance is improved in newer “Just-in-
time(JIT)” JVM’s , which compile methods after
some number of executions, and save machine code to
give compiled-code efficiently thereafter.
• Java performance is impressive for an interpreted
language.
• Due to the use of intermediate byte code.
• Java architecture is also designed to reduce overheads
during runtime.
26
www.infoviaan.com
27. 11. Multithreaded
• Java supports multithreaded programming, which allows
you to write programs that do many things
simultaneously.
• The Java run-time system contains tools to support
multiprocess synchronization and construct smoothly
running interactive systems.
Multitasking –
Multiple work
run
simultaneously
Multithreading –
One process contains
multiple sub
process/lightweight
processes.
27
www.infoviaan.com
28. 12. Distributed
• Java is Distributed Language Means because the program of java
is compiled onto one machine can be easily transferred to
machine and Executes them on another machine because facility
of Bytes Codes So java is Specially designed For Internet Users
which uses the Remote Computers.
• Java provides an extensive library of classes for communicating
,using TCP/IP protocols such as HTTP and FTP.
• This makes creating network connections much easier than in
C/C++.
• You can read and write objects on the remote sites via URL
with the same ease that programmers are used to when read
and write data from and to a file.
• This helps the programmers at remote locations to work
together on the same project.
28
www.infoviaan.com
29. Java Installation
Step 1: Download JDK.
• Go to -
https://www.oracle.com/technetwork/java/javase/downloads/index.ht
ml
Step 2: Install JDK and JRE.
• Run - jdk-8u181-windows-i586.exe (version can be different)
Step 3: Include JDK's "bin" Directory in the PATH.
• Launch "Control Panel" ⇒ (Optional) System and Security ⇒
System ⇒ Click "Advanced system settings" on the left pane.
• Switch to "Advanced" tab ⇒ Push "Environment Variables"
button.
• Under "System Variables" (the bottom pane), scroll down to
select "Path" ⇒ Click "Edit.".
Step 4: Verify the JDK Installation.
• Go to Command prompt and check verify.
Step 5: Write a Hello-World Java Program.
Step 6: Compile and Run the Hello-World Java Program.
29
www.infoviaan.com
30. Hello Program Explanation
public class HelloProgram
{
public static void main(String args[])
{
String name = “Infoviaan”;
System.out.println(“Hello This is
”+name);
}
}
public, class, static, and void are
keywords,
Keywords are always written in small
letters in java.
Class Name
Keyword
Method
Variable
Object reference
30
www.infoviaan.com
31. Program Explanation Cont.
public – Access modifier, shows accessibility of a class or variable
or method to other java classes.
class - used to define a class.
static - is used to assigned memory once in life.
void - is null return type of main method.
String name = “Infoviaan”;
is variable that store a value.
System.out.println(“Hello This is ”+ name);
is method, which display “Hello This is Infoviaan” at console
output.
here + is used for concatenate string.
main – method is the entry point of program execution.
it means program execution start from here.
String args[] – Command line arguments 31
www.infoviaan.com
32. Process to run java program
javac Hello.java
java Hello
Hello World
Compile
Run .main()
32
www.infoviaan.com
34. Java Uses
1. J2SE : - Desktop GUI Applications: Java provides GUI
development through various means like Abstract
Windowing Toolkit (AWT), Swing and JavaFX. (Used to
develop Stand Alone/Desktop based applications)
2. Mobile Applications: - Android applications can be
developed by using the Java programming language
3. Embedded Systems: - It is a combination of hardware and
software that is designed for specific tasks, providing a
function and embedded within a larger electrical system
4. J2EE : - Building and deploying Web-based enterprise
applications.
5. Scientific Applications
34
www.infoviaan.com
35. Questions
1. Why Java is Platform Independent?
2. JDK vs JRE
3. What name of java compiler and Interpreter?
4. Is Java compiler produce machine code?
5. Is Java produce machine code?
6. What is Byte code?
7. Is JVM is Platform Independent or not?
8. Components of JVM
9. Why it is called Virtual machine?
10. Types of Virtual Machine.
11. Types of Java applications
35
www.infoviaan.com