SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
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
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
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.
Principles of OOP
• All object-oriented programming languages provide
mechanisms that help you implement the object-
oriented model.
• They are:
• Encapsulation
• Inheritance
• Polymorphism
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;
}
Advantages of Encapsulation
• Protection
• Consistency
• Allows change
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.
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.
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.
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.
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
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
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.
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.
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.
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).
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.
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.
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.
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.
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.
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.
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.
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++
Origin of Java
• Generation
• James Gosling & Patrick Naughton at 1990
• Goal : to develop distributed system which is
applicable to electronic products(platform
independent)
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.
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.
• 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.
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
Java Platform Editions
• A Java Platform is the set of APIs, class libraries, and
other programs used in developing Java programs for
specific applications.
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
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.
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
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
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
37
Java life, cont..
38
JVM an Portability
• Through the Java VM, the same application is capable of
running on multiple platforms.
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!");
}
}
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

Contenu connexe

Tendances

Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVAKUNAL GADHIA
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core javamahir jain
 
Introduction to java
Introduction to java Introduction to java
Introduction to java Sandeep Rawat
 
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)Michelle Anne Meralpis
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java ProgrammingMath-Circle
 
Introduction to java
Introduction to java Introduction to java
Introduction to java Java Lover
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Mr. Akaash
 
Important features of java
Important features of javaImportant features of java
Important features of javaAL- AMIN
 
JRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAJRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAMehak Tawakley
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in JavaSpotle.ai
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivityTanmoy Barman
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaSaba Ameer
 
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 SanidhyaShravan Sanidhya
 

Tendances (20)

Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVA
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
 
Introduction to java
Introduction to java Introduction to java
Introduction to 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)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
JVM
JVMJVM
JVM
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 
Important features of java
Important features of javaImportant features of java
Important features of java
 
core java
core javacore java
core java
 
QSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and JitQSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and Jit
 
JRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAJRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVA
 
Abstract class in java
Abstract class in javaAbstract class in java
Abstract class in java
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java threads
Java threadsJava threads
Java threads
 
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
 

En vedette

En vedette (8)

Java basic
Java basicJava basic
Java basic
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Java programming course for beginners
Java programming course for beginnersJava programming course for beginners
Java programming course for beginners
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Core java slides
Core java slidesCore java slides
Core java slides
 

Similaire à Introduction to Java Programming

Chapter-1 Introduction.pptx
Chapter-1 Introduction.pptxChapter-1 Introduction.pptx
Chapter-1 Introduction.pptxSumanBhandari40
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to JavaSoumya Suman
 
U1 JAVA.pptx
U1 JAVA.pptxU1 JAVA.pptx
U1 JAVA.pptxmadan r
 
21110113913.pptxElectricity is a type of
21110113913.pptxElectricity is a type of21110113913.pptxElectricity is a type of
21110113913.pptxElectricity is a type ofpandeyritik310
 
itft-Java evolution
itft-Java evolutionitft-Java evolution
itft-Java evolutionAtul Sehdev
 
JAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).pptJAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).pptAliyaJav
 
PPS Java Overview Unit I.ppt
PPS Java Overview Unit I.pptPPS Java Overview Unit I.ppt
PPS Java Overview Unit I.pptRajeshSukte1
 
PPS Java Overview Unit I.ppt
PPS Java Overview Unit I.pptPPS Java Overview Unit I.ppt
PPS Java Overview Unit I.pptCDSukte
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentalsOm Ganesh
 
Introduction to java and it's opportunities
Introduction to java and it's opportunities Introduction to java and it's opportunities
Introduction to java and it's opportunities VigneshManikandan11
 
Lecture-01 _Java Introduction CS 441 Fast
Lecture-01 _Java Introduction CS 441 FastLecture-01 _Java Introduction CS 441 Fast
Lecture-01 _Java Introduction CS 441 FastUzairSaeed18
 

Similaire à Introduction to Java Programming (20)

L1 basics
L1 basicsL1 basics
L1 basics
 
Chapter-1 Introduction.pptx
Chapter-1 Introduction.pptxChapter-1 Introduction.pptx
Chapter-1 Introduction.pptx
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
1 java introduction
1 java introduction1 java introduction
1 java introduction
 
1 java intro
1 java intro1 java intro
1 java intro
 
U1 JAVA.pptx
U1 JAVA.pptxU1 JAVA.pptx
U1 JAVA.pptx
 
Java (1)
Java (1)Java (1)
Java (1)
 
21110113913.pptxElectricity is a type of
21110113913.pptxElectricity is a type of21110113913.pptxElectricity is a type of
21110113913.pptxElectricity is a type of
 
itft-Java evolution
itft-Java evolutionitft-Java evolution
itft-Java evolution
 
JAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).pptJAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).ppt
 
JAVA INTRODUCTION - 1
JAVA INTRODUCTION - 1JAVA INTRODUCTION - 1
JAVA INTRODUCTION - 1
 
PPS Java Overview Unit I.ppt
PPS Java Overview Unit I.pptPPS Java Overview Unit I.ppt
PPS Java Overview Unit I.ppt
 
PPS Java Overview Unit I.ppt
PPS Java Overview Unit I.pptPPS Java Overview Unit I.ppt
PPS Java Overview Unit I.ppt
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Introduction to java and it's opportunities
Introduction to java and it's opportunities Introduction to java and it's opportunities
Introduction to java and it's opportunities
 
Basic of Java
Basic of JavaBasic of Java
Basic of Java
 
Lecture-01 _Java Introduction CS 441 Fast
Lecture-01 _Java Introduction CS 441 FastLecture-01 _Java Introduction CS 441 Fast
Lecture-01 _Java Introduction CS 441 Fast
 
java completed units.docx
java completed units.docxjava completed units.docx
java completed units.docx
 

Plus de Ravi Kant Sahu

Plus de Ravi Kant Sahu (12)

Event handling
Event handlingEvent handling
Event handling
 
Multi threading
Multi threadingMulti threading
Multi threading
 
Distributed Programming (RMI)
Distributed Programming (RMI)Distributed Programming (RMI)
Distributed Programming (RMI)
 
Networking
NetworkingNetworking
Networking
 
Servlets
ServletsServlets
Servlets
 
Java beans
Java beansJava beans
Java beans
 
Applets
AppletsApplets
Applets
 
Internationalization
InternationalizationInternationalization
Internationalization
 
Exception handling
Exception handlingException handling
Exception handling
 
Packages
PackagesPackages
Packages
 
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)
 

Dernier

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 

Dernier (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 

Introduction to Java Programming

  • 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
  • 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
  • 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.
  • 5. Principles of OOP • All object-oriented programming languages provide mechanisms that help you implement the object- oriented model. • They are: • Encapsulation • Inheritance • Polymorphism
  • 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; }
  • 7. Advantages of Encapsulation • Protection • Consistency • Allows change
  • 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.
  • 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.
  • 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.
  • 11. 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.
  • 12. 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
  • 13. 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
  • 14. 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.
  • 15. 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.
  • 16. 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.
  • 17. 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).
  • 18. 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.
  • 19. 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.
  • 20. 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.
  • 21. 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.
  • 22. 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.
  • 23. 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.
  • 24. 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.
  • 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++
  • 26. Origin of Java • Generation • James Gosling & Patrick Naughton at 1990 • Goal : to develop distributed system which is applicable to electronic products(platform independent)
  • 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.
  • 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.
  • 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.
  • 30. 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
  • 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.
  • 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
  • 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.
  • 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
  • 35. 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
  • 36. 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
  • 38. 38 JVM an Portability • Through the Java VM, the same application is capable of running on multiple platforms.
  • 39. 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!"); } }
  • 40. 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