SlideShare a Scribd company logo
1 of 42
Download to read offline
PROGRAMMING IN JAVA
Introduction to JAVA
Lecture 1: Genesis and overview of Java
By
Ravi Kant Sahu
Asst. Professor, LPU
Contents
• What is JAVA?
• What is OOP?
• Why Java?
• Characteristics of JAVA
• Overview of Java.
• The difference between Java and C++?
• A Simple JAVA Program
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
What is JAVA?
• Developed by Sun Microsystems (James Gosling)
• A general-purpose Object-Oriented language
• Based on C/C++
• Designed for easy Web/Internet applications
• Widespread acceptance
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
What is Object Oriented Programming?
Object-oriented programming is a method of
implementation in which programs are organized as
cooperative collections of objects, each of which
represents an instance of some class, and whose classes
are all members of one or more hierarchy of classes
united via inheritance relationships.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Principles of OOP
• All object-oriented programming languages provide
mechanisms that help you implement the object-
oriented model.
• They are:
• Encapsulation
• Inheritance
• Polymorphism
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Data Encapsulation
Encapsulation is the mechanism that binds together code
and the data it manipulates, and keeps both safe from
outside interference and misuse.
class Account {
int x=10;
float withdraw();
void deposit(float amount);
float balance;
}
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Advantages of Encapsulation
• Protection
• Consistency
• Allows change
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Inheritance
• Inheritance is the process by which one object acquires the
properties of another object.
• A class that is derived from another class is called a subclass
(also a derived class, extended class, or child class).
• The class from which the subclass is derived is called a super
class (also a base class or a parent class).
• A class which is a subtype of a more general class is said to
be inherited from it.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Inheritance cont’d
• The sub-class inherits the base class’ data members and
member functions.
• A sub-class has all data members of its base-class plus its
own.
• A sub-class has all member functions of its base class (with
changes) plus its own.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Polymorphism
• Polymorphism refers to a programming language's ability to
process objects differently depending on their data type or
class.
• Generally, the ability to appear in many forms.
• More specifically, it is the ability to redefine methods for
derived classes.
• For example, given a base class shape, polymorphism
enables the programmer to define different area methods for
any number of derived classes, such as circles, rectangles and
triangles. No matter what shape an object is, applying the
area method to it will return the correct results.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Why Java?
Java is the Internet programming language.
Java enables users to develop and deploy applications
on the Internet for servers, desktop computers, and
small hand-held devices.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Java, Web, and Beyond
• Java Applets
• Java Web Applications
• Java can also be used to develop applications for
hand-held devices such as Palm and cell phones
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Characteristics of Java
•Java Is Simple
•Java Is Object-Oriented
•Java Is Distributed
•Java Is Interpreted
•Java Is Robust
•Java Is Secure
•Java Is Architecture-Neutral
•Java Is Portable
•Java's Performance
•Java Is Multithreaded
•Java Is Dynamic
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Characteristics of Java
•Java Is Simple
•Java Is Object-Oriented
•Java Is Distributed
•Java Is Interpreted
•Java Is Robust
•Java Is Secure
•Java Is Architecture-Neutral
•Java Is Portable
•Java's Performance
•Java Is Multithreaded
•Java Is Dynamic
Java is partially modeled on C++, but
greatly simplified and improved. Some
people refer to Java as "C++--" because it
is like C++ but with more functionality and
fewer negative aspects.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Characteristics of Java
•Java Is Simple
•Java Is Object-Oriented
•Java Is Distributed
•Java Is Interpreted
•Java Is Robust
•Java Is Secure
•Java Is Architecture-Neutral
•Java Is Portable
•Java's Performance
•Java Is Multithreaded
•Java Is Dynamic
Java is inherently object-oriented.
Although many object-oriented
languages began strictly as procedural
languages, Java was designed from
the start to be object-oriented. Object-
oriented programming (OOP) is a
popular programming approach that is
replacing traditional procedural
programming techniques.
One of the central issues in software
development is how to reuse code.
Object-oriented programming provides
great flexibility, modularity, clarity, and
reusability through encapsulation,
inheritance, and polymorphism.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Characteristics of Java
•Java Is Simple
•Java Is Object-Oriented
•Java Is Distributed
•Java Is Interpreted
•Java Is Robust
•Java Is Secure
•Java Is Architecture-Neutral
•Java Is Portable
•Java's Performance
•Java Is Multithreaded
•Java Is Dynamic
Distributed computing involves several
computers working together on a
network. Java is designed to make
distributed computing easy. Since
networking capability is inherently
integrated into Java, writing network
programs is like sending and receiving
data to and from a file.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Characteristics of Java
•Java Is Simple
•Java Is Object-Oriented
•Java Is Distributed
•Java Is Interpreted
•Java Is Robust
•Java Is Secure
•Java Is Architecture-Neutral
•Java Is Portable
•Java's Performance
•Java Is Multithreaded
•Java Is Dynamic
You need an interpreter to run Java
programs. The programs are compiled
into the Java Virtual Machine code
called bytecode. The bytecode is
machine-independent and can run on
any machine that has a Java
interpreter, which is part of the Java
Virtual Machine (JVM).
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Characteristics of Java
•Java Is Simple
•Java Is Object-Oriented
•Java Is Distributed
•Java Is Interpreted
•Java Is Robust
•Java Is Secure
•Java Is Architecture-Neutral
•Java Is Portable
•Java's Performance
•Java Is Multithreaded
•Java Is Dynamic
Java compilers can detect many
problems that would first show up at
execution time in other languages.
Java has eliminated certain types of
error-prone programming constructs
found in other languages.
Java has a runtime exception-handling
feature to provide programming
support for robustness.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Characteristics of Java
•Java Is Simple
•Java Is Object-Oriented
•Java Is Distributed
•Java Is Interpreted
•Java Is Robust
•Java Is Secure
•Java Is Architecture-Neutral
•Java Is Portable
•Java's Performance
•Java Is Multithreaded
•Java Is Dynamic
Java implements several security
mechanisms to protect your system
against harm caused by stray
programs.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Characteristics of Java
•Java Is Simple
•Java Is Object-Oriented
•Java Is Distributed
•Java Is Interpreted
•Java Is Robust
•Java Is Secure
•Java Is Architecture-Neutral
•Java Is Portable
•Java's Performance
•Java Is Multithreaded
•Java Is Dynamic
Write once, run anywhere
With a Java Virtual Machine (JVM),
you can write one program that will
run on any platform.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Characteristics of Java
•Java Is Simple
•Java Is Object-Oriented
•Java Is Distributed
•Java Is Interpreted
•Java Is Robust
•Java Is Secure
•Java Is Architecture-Neutral
•Java Is Portable
•Java's Performance
•Java Is Multithreaded
•Java Is Dynamic
Because Java is architecture neutral,
Java programs are portable. They can
be run on any platform without being
recompiled.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Characteristics of Java
•Java Is Simple
•Java Is Object-Oriented
•Java Is Distributed
•Java Is Interpreted
•Java Is Robust
•Java Is Secure
•Java Is Architecture-Neutral
•Java Is Portable
•Java's Performance
•Java Is Multithreaded
•Java Is Dynamic
Java’s performance Because Java is
architecture neutral, Java programs are
portable. They can be run on any
platform without being recompiled.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Characteristics of Java
•Java Is Simple
•Java Is Object-Oriented
•Java Is Distributed
•Java Is Interpreted
•Java Is Robust
•Java Is Secure
•Java Is Architecture-Neutral
•Java Is Portable
•Java's Performance
•Java Is Multithreaded
•Java Is Dynamic
Multithread programming is smoothly
integrated in Java, whereas in other
languages you have to call procedures
specific to the operating system to enable
multithreading.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Characteristics of Java
•Java Is Simple
•Java Is Object-Oriented
•Java Is Distributed
•Java Is Interpreted
•Java Is Robust
•Java Is Secure
•Java Is Architecture-Neutral
•Java Is Portable
•Java's Performance
•Java Is Multithreaded
•Java Is Dynamic
Java was designed to adapt to an evolving
environment. New code can be loaded on the
fly without recompilation. There is no need for
developers to create, and for users to install,
major new software versions. New features can
be incorporated transparently as needed.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Java Disadvantages
• Slower than compiled language such as C
• an experiment in 1999 showed that Java was 3 or 4
times slower than C or C++
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Origin of Java
• Generation
• James Gosling & Patrick Naughton at 1990
• Goal : to develop distributed system which is
applicable to electronic products(platform
independent)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
James Gosling
• James Gosling is generally
credited as the inventor of the Java
programming language
• He was the first designer of Java
and implemented its original
compiler and virtual machine
• He is also known as the Father of
Java.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Brief History of Java
• In 1990, Sun Microsystems began an internal project known as the
Green Project to work on a new technology.
• In 1992, the Green Project was spun off and its interest directed
toward building highly interactive devices for the cable TV industry.
This failed to materialize.
• In 1994, the focus of the original team was re-targeted, this time to
the use of Internet technology. A small web browser called HotJava
was written.
• Oak was renamed to Java after learning that Oak had already been
trademarked.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
• In 1995, Java was first publicly released.
• In 1996, Java Development Kit (JDK) 1.0 was released.
• In 2002, JDK 1.4 (codename Merlin) was released, the most
widely used version.
• In 2004, JDK 5.0 (codename Tiger) was released, the latest
version.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
JDK Versions
•JDK 1.02 (1995) … 250 classes
•JDK 1.1 (1996) … 500 classes
•JDK 1.2 (1998) … 2300 classes
•JDK 1.3 (2000) … 2300 classes
•JDK 1.4 (2002) … 2300 classes
•JDK 1.5 (2004) … 3500 classes
•JDK 1.6 (2006) … 3500 classes
•JDK 1.7 (2011) … 3500 classes
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Java Platform Editions
• A Java Platform is the set of APIs, class libraries, and
other programs used in developing Java programs for
specific applications.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
There are 3 Java Platform Editions
1. Java 2 Platform, Standard Edition (J2SE)
• Core Java Platform targeting applications running on
workstations
2. Java 2 Platform, Enterprise Edition (J2EE)
• Component-based approach to developing distributed,
multi-tier enterprise applications
3. Java 2 Platform, Micro Edition (J2ME)
• Targeted at small, stand-alone or connectable
consumer and embedded devices
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Java Development Kit (JDK)
Java Development Kit (JDK)
• Is a set of Java tools for developing Java programs
• Consists of Java API, Java Compiler, and JVM
Java Application Programming Interface (API)
• Is prewritten code, organized into packages of similar topics
Java Virtual Machine
Java API
MyProgram.java
Hardware - Based Platform
JDK
JRE
Java Virtual
Machine (JVM) is
an execution engine
that runs compiled
Java byte code.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Structure Overview of Java
Hardware Platform
OS Platform
Java Virtual Machine
Java APIs
Sparc, Intel, Mac, HP ...
Solaris, Windows, Mac, Linux ..
OS application Language Primitives
Auxiliary Window Tookit
JDBCRMI
Servlet API JavaBeans
Etc.
JDBC Drivers
Web Server
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Java life cycle
•Java programs normally undergo four phases
• Edit
•Programmer writes program (and stores program on
disk)
• Compile
•Compiler creates byte-codes from program (.class)
• Load
•Class loader stores byte-codes in memory
• Execute
•Interpreter: translates byte-codes into machine language
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Java life cycle
• Source code (.java)
• Compiled into Byte codes (.class) , as (.exe) in c++
– The Java Application Programming Interface
(API)
• a large collection of ready-made software components.
It is grouped into libraries of related classes and
interfaces; these libraries are known as packages.
– Java Virtual Machine (JVM)
– Machine code
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Java life, cont..
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
JVM an Portability
• Through the Java VM, the same application is capable of
running on multiple platforms.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
A Simple Java Program
//This program prints Welcome to Java!
public class Welcome
{
public static void main(String[] args)
{
System.out.println("Welcome to Java!");
}
}
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Compiling Java Source Code
Java was designed to run object programs on any platform.
With Java, you write the program once, and compile the source
program into a special type of object code, known as bytecode.
The byte-code can then run on any computer with a Java Virtual
Machine, as shown below.
Java Virtual Machine is a software
that interprets Java byte-code.
Java Bytecode
Java Virtual
Machine
Any
Computer
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)

More Related Content

What's hot

1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
Jay Patel
 
Abstraction in java
Abstraction in javaAbstraction in java
Abstraction in java
sawarkar17
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Tech_MX
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
pm2214
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
thinkphp
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
aitrichtech
 

What's hot (20)

1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
core java
core javacore java
core java
 
Abstraction in java
Abstraction in javaAbstraction in java
Abstraction in java
 
WHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAWHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVA
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Java package
Java packageJava package
Java package
 
Java
JavaJava
Java
 
Training on Core java | PPT Presentation | Shravan Sanidhya
Training on Core java | PPT Presentation | Shravan SanidhyaTraining on Core java | PPT Presentation | Shravan Sanidhya
Training on Core java | PPT Presentation | Shravan Sanidhya
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Java string handling
Java string handlingJava string handling
Java string handling
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
JAVA PROGRAMMING
JAVA PROGRAMMING JAVA PROGRAMMING
JAVA PROGRAMMING
 
Features of java
Features of javaFeatures of java
Features of java
 

Viewers also liked (10)

Java Notes
Java NotesJava Notes
Java Notes
 
History of Java 1/2
History of Java 1/2History of Java 1/2
History of Java 1/2
 
Collection framework
Collection frameworkCollection framework
Collection framework
 
Java generics final
Java generics finalJava generics final
Java generics final
 
History of java
History of javaHistory of java
History of java
 
Cryptography
Cryptography Cryptography
Cryptography
 
Jdbc
JdbcJdbc
Jdbc
 
Multi threading
Multi threadingMulti threading
Multi threading
 
History of java'
History of java'History of java'
History of java'
 
Control structures in Java
Control structures in JavaControl structures in Java
Control structures in Java
 

Similar to Genesis and Overview of Java

Similar to Genesis and Overview of Java (20)

L1 basics
L1 basicsL1 basics
L1 basics
 
L1 basics
L1 basicsL1 basics
L1 basics
 
2. Basics of Java
2. Basics of Java2. Basics of Java
2. Basics of Java
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
U1 JAVA.pptx
U1 JAVA.pptxU1 JAVA.pptx
U1 JAVA.pptx
 
Java assignment help
Java assignment helpJava assignment help
Java assignment help
 
Industrial Training Report on Java Technology.
Industrial Training Report on Java Technology.Industrial Training Report on Java Technology.
Industrial Training Report on Java Technology.
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
 
Java programming language
Java programming languageJava programming language
Java programming language
 
concept of core java
concept of core java concept of core java
concept of core java
 
Java Introduction - Quipoin.pptx
Java Introduction - Quipoin.pptxJava Introduction - Quipoin.pptx
Java Introduction - Quipoin.pptx
 
Core java
Core java Core java
Core java
 
oop unit1.pptx
oop unit1.pptxoop unit1.pptx
oop unit1.pptx
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
INTRODUCTION_O1.pptx
INTRODUCTION_O1.pptxINTRODUCTION_O1.pptx
INTRODUCTION_O1.pptx
 
CS8392 OOP
CS8392 OOPCS8392 OOP
CS8392 OOP
 
Java buzzwords.pptx
Java buzzwords.pptxJava buzzwords.pptx
Java buzzwords.pptx
 
Core java learning path for beginners
Core java learning path for beginnersCore java learning path for beginners
Core java learning path for beginners
 
Top 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed AnswersTop 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed Answers
 

More from Ravi_Kant_Sahu (19)

Common Programming Errors by Beginners in Java
Common Programming Errors by Beginners in JavaCommon Programming Errors by Beginners in Java
Common Programming Errors by Beginners in Java
 
Gui programming (awt)
Gui programming (awt)Gui programming (awt)
Gui programming (awt)
 
Event handling
Event handlingEvent handling
Event handling
 
Basic IO
Basic IOBasic IO
Basic IO
 
List classes
List classesList classes
List classes
 
String handling(string buffer class)
String handling(string buffer class)String handling(string buffer class)
String handling(string buffer class)
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)
 
Packages
PackagesPackages
Packages
 
Generics
GenericsGenerics
Generics
 
Array
ArrayArray
Array
 
Keywords and classes
Keywords and classesKeywords and classes
Keywords and classes
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
 
Methods and constructors
Methods and constructorsMethods and constructors
Methods and constructors
 
Java keywords
Java keywordsJava keywords
Java keywords
 
Inheritance
InheritanceInheritance
Inheritance
 
Classes and Nested Classes in Java
Classes and Nested Classes in JavaClasses and Nested Classes in Java
Classes and Nested Classes in Java
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Swing api
Swing apiSwing api
Swing api
 
L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variables
 

Recently uploaded

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
QucHHunhnh
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

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
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
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...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
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.
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
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Ữ Â...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
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
 

Genesis and Overview of Java

  • 1. PROGRAMMING IN JAVA Introduction to JAVA Lecture 1: Genesis and overview of Java By Ravi Kant Sahu Asst. Professor, LPU
  • 2. Contents • What is JAVA? • What is OOP? • Why Java? • Characteristics of JAVA • Overview of Java. • The difference between Java and C++? • A Simple JAVA Program Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 3. What is JAVA? • Developed by Sun Microsystems (James Gosling) • A general-purpose Object-Oriented language • Based on C/C++ • Designed for easy Web/Internet applications • Widespread acceptance Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 4. What is Object Oriented Programming? Object-oriented programming is a method of implementation in which programs are organized as cooperative collections of objects, each of which represents an instance of some class, and whose classes are all members of one or more hierarchy of classes united via inheritance relationships. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 5. Principles of OOP • All object-oriented programming languages provide mechanisms that help you implement the object- oriented model. • They are: • Encapsulation • Inheritance • Polymorphism Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 6. Data Encapsulation Encapsulation is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse. class Account { int x=10; float withdraw(); void deposit(float amount); float balance; } Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 7. Advantages of Encapsulation • Protection • Consistency • Allows change Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 8. Inheritance • Inheritance is the process by which one object acquires the properties of another object. • A class that is derived from another class is called a subclass (also a derived class, extended class, or child class). • The class from which the subclass is derived is called a super class (also a base class or a parent class). • A class which is a subtype of a more general class is said to be inherited from it. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 9. Inheritance cont’d • The sub-class inherits the base class’ data members and member functions. • A sub-class has all data members of its base-class plus its own. • A sub-class has all member functions of its base class (with changes) plus its own. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 10. Polymorphism • Polymorphism refers to a programming language's ability to process objects differently depending on their data type or class. • Generally, the ability to appear in many forms. • More specifically, it is the ability to redefine methods for derived classes. • For example, given a base class shape, polymorphism enables the programmer to define different area methods for any number of derived classes, such as circles, rectangles and triangles. No matter what shape an object is, applying the area method to it will return the correct results. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 11. Why Java? Java is the Internet programming language. Java enables users to develop and deploy applications on the Internet for servers, desktop computers, and small hand-held devices. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 12. Java, Web, and Beyond • Java Applets • Java Web Applications • Java can also be used to develop applications for hand-held devices such as Palm and cell phones Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 13. Characteristics of Java •Java Is Simple •Java Is Object-Oriented •Java Is Distributed •Java Is Interpreted •Java Is Robust •Java Is Secure •Java Is Architecture-Neutral •Java Is Portable •Java's Performance •Java Is Multithreaded •Java Is Dynamic Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 14. Characteristics of Java •Java Is Simple •Java Is Object-Oriented •Java Is Distributed •Java Is Interpreted •Java Is Robust •Java Is Secure •Java Is Architecture-Neutral •Java Is Portable •Java's Performance •Java Is Multithreaded •Java Is Dynamic Java is partially modeled on C++, but greatly simplified and improved. Some people refer to Java as "C++--" because it is like C++ but with more functionality and fewer negative aspects. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 15. Characteristics of Java •Java Is Simple •Java Is Object-Oriented •Java Is Distributed •Java Is Interpreted •Java Is Robust •Java Is Secure •Java Is Architecture-Neutral •Java Is Portable •Java's Performance •Java Is Multithreaded •Java Is Dynamic Java is inherently object-oriented. Although many object-oriented languages began strictly as procedural languages, Java was designed from the start to be object-oriented. Object- oriented programming (OOP) is a popular programming approach that is replacing traditional procedural programming techniques. One of the central issues in software development is how to reuse code. Object-oriented programming provides great flexibility, modularity, clarity, and reusability through encapsulation, inheritance, and polymorphism. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 16. Characteristics of Java •Java Is Simple •Java Is Object-Oriented •Java Is Distributed •Java Is Interpreted •Java Is Robust •Java Is Secure •Java Is Architecture-Neutral •Java Is Portable •Java's Performance •Java Is Multithreaded •Java Is Dynamic Distributed computing involves several computers working together on a network. Java is designed to make distributed computing easy. Since networking capability is inherently integrated into Java, writing network programs is like sending and receiving data to and from a file. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 17. Characteristics of Java •Java Is Simple •Java Is Object-Oriented •Java Is Distributed •Java Is Interpreted •Java Is Robust •Java Is Secure •Java Is Architecture-Neutral •Java Is Portable •Java's Performance •Java Is Multithreaded •Java Is Dynamic You need an interpreter to run Java programs. The programs are compiled into the Java Virtual Machine code called bytecode. The bytecode is machine-independent and can run on any machine that has a Java interpreter, which is part of the Java Virtual Machine (JVM). Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 18. Characteristics of Java •Java Is Simple •Java Is Object-Oriented •Java Is Distributed •Java Is Interpreted •Java Is Robust •Java Is Secure •Java Is Architecture-Neutral •Java Is Portable •Java's Performance •Java Is Multithreaded •Java Is Dynamic Java compilers can detect many problems that would first show up at execution time in other languages. Java has eliminated certain types of error-prone programming constructs found in other languages. Java has a runtime exception-handling feature to provide programming support for robustness. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 19. Characteristics of Java •Java Is Simple •Java Is Object-Oriented •Java Is Distributed •Java Is Interpreted •Java Is Robust •Java Is Secure •Java Is Architecture-Neutral •Java Is Portable •Java's Performance •Java Is Multithreaded •Java Is Dynamic Java implements several security mechanisms to protect your system against harm caused by stray programs. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 20. Characteristics of Java •Java Is Simple •Java Is Object-Oriented •Java Is Distributed •Java Is Interpreted •Java Is Robust •Java Is Secure •Java Is Architecture-Neutral •Java Is Portable •Java's Performance •Java Is Multithreaded •Java Is Dynamic Write once, run anywhere With a Java Virtual Machine (JVM), you can write one program that will run on any platform. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 21. Characteristics of Java •Java Is Simple •Java Is Object-Oriented •Java Is Distributed •Java Is Interpreted •Java Is Robust •Java Is Secure •Java Is Architecture-Neutral •Java Is Portable •Java's Performance •Java Is Multithreaded •Java Is Dynamic Because Java is architecture neutral, Java programs are portable. They can be run on any platform without being recompiled. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 22. Characteristics of Java •Java Is Simple •Java Is Object-Oriented •Java Is Distributed •Java Is Interpreted •Java Is Robust •Java Is Secure •Java Is Architecture-Neutral •Java Is Portable •Java's Performance •Java Is Multithreaded •Java Is Dynamic Java’s performance Because Java is architecture neutral, Java programs are portable. They can be run on any platform without being recompiled. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 23. Characteristics of Java •Java Is Simple •Java Is Object-Oriented •Java Is Distributed •Java Is Interpreted •Java Is Robust •Java Is Secure •Java Is Architecture-Neutral •Java Is Portable •Java's Performance •Java Is Multithreaded •Java Is Dynamic Multithread programming is smoothly integrated in Java, whereas in other languages you have to call procedures specific to the operating system to enable multithreading. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 24. Characteristics of Java •Java Is Simple •Java Is Object-Oriented •Java Is Distributed •Java Is Interpreted •Java Is Robust •Java Is Secure •Java Is Architecture-Neutral •Java Is Portable •Java's Performance •Java Is Multithreaded •Java Is Dynamic Java was designed to adapt to an evolving environment. New code can be loaded on the fly without recompilation. There is no need for developers to create, and for users to install, major new software versions. New features can be incorporated transparently as needed. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 25. Java Disadvantages • Slower than compiled language such as C • an experiment in 1999 showed that Java was 3 or 4 times slower than C or C++ Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 26. Origin of Java • Generation • James Gosling & Patrick Naughton at 1990 • Goal : to develop distributed system which is applicable to electronic products(platform independent) Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 27. James Gosling • James Gosling is generally credited as the inventor of the Java programming language • He was the first designer of Java and implemented its original compiler and virtual machine • He is also known as the Father of Java. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 28. Brief History of Java • In 1990, Sun Microsystems began an internal project known as the Green Project to work on a new technology. • In 1992, the Green Project was spun off and its interest directed toward building highly interactive devices for the cable TV industry. This failed to materialize. • In 1994, the focus of the original team was re-targeted, this time to the use of Internet technology. A small web browser called HotJava was written. • Oak was renamed to Java after learning that Oak had already been trademarked. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 29. • In 1995, Java was first publicly released. • In 1996, Java Development Kit (JDK) 1.0 was released. • In 2002, JDK 1.4 (codename Merlin) was released, the most widely used version. • In 2004, JDK 5.0 (codename Tiger) was released, the latest version. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 30. JDK Versions •JDK 1.02 (1995) … 250 classes •JDK 1.1 (1996) … 500 classes •JDK 1.2 (1998) … 2300 classes •JDK 1.3 (2000) … 2300 classes •JDK 1.4 (2002) … 2300 classes •JDK 1.5 (2004) … 3500 classes •JDK 1.6 (2006) … 3500 classes •JDK 1.7 (2011) … 3500 classes Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 31. Java Platform Editions • A Java Platform is the set of APIs, class libraries, and other programs used in developing Java programs for specific applications. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 32. There are 3 Java Platform Editions 1. Java 2 Platform, Standard Edition (J2SE) • Core Java Platform targeting applications running on workstations 2. Java 2 Platform, Enterprise Edition (J2EE) • Component-based approach to developing distributed, multi-tier enterprise applications 3. Java 2 Platform, Micro Edition (J2ME) • Targeted at small, stand-alone or connectable consumer and embedded devices Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 33. Java Development Kit (JDK) Java Development Kit (JDK) • Is a set of Java tools for developing Java programs • Consists of Java API, Java Compiler, and JVM Java Application Programming Interface (API) • Is prewritten code, organized into packages of similar topics Java Virtual Machine Java API MyProgram.java Hardware - Based Platform JDK JRE Java Virtual Machine (JVM) is an execution engine that runs compiled Java byte code. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 34. Structure Overview of Java Hardware Platform OS Platform Java Virtual Machine Java APIs Sparc, Intel, Mac, HP ... Solaris, Windows, Mac, Linux .. OS application Language Primitives Auxiliary Window Tookit JDBCRMI Servlet API JavaBeans Etc. JDBC Drivers Web Server Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 35. Java life cycle •Java programs normally undergo four phases • Edit •Programmer writes program (and stores program on disk) • Compile •Compiler creates byte-codes from program (.class) • Load •Class loader stores byte-codes in memory • Execute •Interpreter: translates byte-codes into machine language Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 36. Java life cycle • Source code (.java) • Compiled into Byte codes (.class) , as (.exe) in c++ – The Java Application Programming Interface (API) • a large collection of ready-made software components. It is grouped into libraries of related classes and interfaces; these libraries are known as packages. – Java Virtual Machine (JVM) – Machine code Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 37. Java life, cont.. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 38. JVM an Portability • Through the Java VM, the same application is capable of running on multiple platforms. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 39. A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { System.out.println("Welcome to Java!"); } } Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 40. Compiling Java Source Code Java was designed to run object programs on any platform. With Java, you write the program once, and compile the source program into a special type of object code, known as bytecode. The byte-code can then run on any computer with a Java Virtual Machine, as shown below. Java Virtual Machine is a software that interprets Java byte-code. Java Bytecode Java Virtual Machine Any Computer Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 41.
  • 42. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)