SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Chapter 1 – Introduction to Java and OOP
Concepts
By
Sirage Zeynu (M.Tech)
Computing Science
Debre Berhan University
13-04-2021 Introduction to Java and OO Concepts 2
 Computer is a device that performs tasks based on given set of step-
by-step instructions (procedures)
 These set of procedures (step-by-step instructions) are called
algorithms also called computer programs or software's.
 Computing is a constantly changing our world and our environment.
 The way in which we tell/give the set of procedures or programs to a computer are
called programming languages. Examples are: C++, java, C#...
 In order to write a program you need to go through several stages. These are
1. Type the text of the program into the computer
2. Translate the program text into a form the computer can use
3. Run the translated program
Basics of programming
13-04-2021 Introduction to Java and OO Concepts 3
 There are different types of programming languages based on the
philosophy they use.
Procedural Programming:
 is a programming paradigm/modelling approach in which a list of step-
by-step instructions telling a computer, what to do one after the other
 linear order of execution from the first statement to the end.
Example C, FORTRAN, Pascal, and Basic.
 The procedural-oriented programs are made up of functions. Functions
are less reusable
 It is very difficult to copy a function from one program and reuse in
another program because the function is likely to reference the global
variables and other functions.
 The procedural languages are not suitable of high-level abstraction for
solving real life problems.
Programming paradigms
13-04-2021 Introduction to Java and OO Concepts 4
Object oriented programming(OOP):
 is a programming paradigm/modelling approach that
represents concepts as "objects" that have
◦ data fields (attributes that describe the object) and
◦ Associated procedures known as methods/functions that
operate or manage the data.
◦ OOP languages permit higher level of abstraction for
solving real-life problems.
◦ The basic unit of OOP is a class, which encapsulates both
the static properties and dynamic operations
Examples : C++, Java, PHP, C#...
Programming paradigms
13-04-2021 Introduction to Java and OO Concepts 5
 Java programming language was originally developed by
Sun Microsystems which was initiated by James Gosling and
released in 1995 as core component of Sun Microsystems' Java
platform (Java 1.0 [J2SE]).
 The latest release of the Java Standard Edition is Java SE 11.
 With the advancement of Java and its widespread popularity,
multiple configurations were built to suit various types of
platforms.
 For example: J2EE for Enterprise Applications, J2ME for Mobile
Applications.
 The new J2 versions were renamed as Java SE, Java EE, and Java
ME respectively.
 Java is guaranteed to be Write Once, Run Anywhere.
Java Overview
13-04-2021 Introduction to Java and OO Concepts 6
 Object Oriented: In Java, everything is an Object. Java can be
easily extended since it is based on the Object model.
 Simple: Java is designed to be easy to learn. If you understand
the basic concept of OOP, Java would be easy to master.
 Secure: With Java's secure feature, it enables to develop virus-
free, tamper-free systems. Authentication techniques are based
on public-key encryption
 Architectural-neutral: Java compiler generates an
architecture-neutral object file format, which makes the
compiled code to be executable on many processors, with the
presence of Java runtime system
Features of Java programming language
13-04-2021 Introduction to Java and OO Concepts 7
 Robust: Java makes an effort to eliminate error prone situations by
emphasizing mainly on compile time error checking and runtime
checking.
 Multithreaded: With Java's multithreaded feature, it is possible to write
programs that can do many tasks simultaneously. This design feature
allows developers to construct smoothly running interactive
applications.
 High Performance: With the use of Just-In-Time compilers, Java
enables high performance.
 Dynamic: Java is considered to be more dynamic than C or C++ since it
is designed to adapt to an evolving environment.
Features of Java programming language
13-04-2021 Introduction to Java and OO Concepts 8
 Distributed: Java is designed for the distributed environment of the internet.
 Compiled and interpreted: java is both compiled and interpreted.
 The Java compiler translates the program into an intermediate language called Java
byte-codes.
 Java byte-codes are platform-independent – this means they can be run on different
operating systems (e.g. Windows, Linux, Mac...). There are different Java interpreters
for different platforms. These interpreters parse and run each of the Java byte-code
instructions to each machine code in which the machine can understand. The
interpreters are usually called java Virtual Machine.
 It is called a Virtual Machine because it is like a computer that does not physically exist
 the JVM exists only within the memory of the computer. The Java byte-codes are like a
set of machine code instructions for the JVM.
 Compilation only needs to happen one time, whereas interpretation happens every time
the program is executed
Features of Java programming language
13-04-2021 Introduction to Java and OO Concepts 9
 Java environment includes a large number of development tools and
hundreds of classes & methods.
 You can download the most up-to-date JDK and its documentation from
java.sun.com/
 The development tools are part of the system known as java development
kit (JDK).
 The set of classes and methods are part of the Java Standard Library(API),
also known as Application Programming Interface(API).
JAVA development Environment
13-04-2021 Introduction to Java and OO Concepts 10
 Comes with a collection of tools that are used for developing and
running java programs. They include
◦ javac --- java compiler
◦ java --- java interpreter
◦ jdb --- java debugger etc...
 So, to develop java programs, we need to install jdk. And then we can
use our own text editor to write java source code. Or instead of using our
own text editor, another option we can use is installing other tools or
APIs like Net-beans and Eclipse to easily code, compile and run java
programs.
Java Development Kit (JDK)
13-04-2021 Introduction to Java and OO Concepts 11
 The Java API consists of many built-in classes and methods that we can
use in our code. These classes and methods/functions are again grouped
into a form packages. Package is a collection of related classes together.
Some of the most commonly used packages are the following:
 Language support package (java.lang) – classes required for
implementing basic features of Java.
 Utilities package (java.util) – classes that provide various utility functions
such as date and time functions.
 Input/Output package (java.io) – classes required for manipulation of input/output
to/from programs
 Networking Package (java.net) – classes used for communicating with other
programs/PCs over networks and internet
 Applet Package (java.applet) – classes that are used to create Java applets.
Main Java API packages include:
13-04-2021 Introduction to Java and OO Concepts 12
Java programs normally go through five phases—edit, compile, load, verify and exe- cute.
13-04-2021 Introduction to Java and OO Concepts 13
13-04-2021 Introduction to Java and OO Concepts 14
 Objects
 classes
 Data abstraction
 encapsulation
 Inheritance
 Polymorphism
 Dynamic (late) binding
 Message communication
The basic concepts of OO are
13-04-2021 Introduction to Java and OO Concepts 15
classes
 A ‘class’ is a software design which describes the general properties of
something which the software is modelling.
 A class is the definition of a set of objects or a class is the design of an
object. A class models a static view of objects which exist in the system
users' world.
 A class can be visualized as a three-compartment box, as illustrated:
 Name (or identity): identifies the class.
 Variables (or attribute, state, field): contains the static attributes of the
class.
 Methods (or behaviours, function, operation): contains the dynamic
behaviors of the class.
The basic concepts of OOP
13-04-2021 Introduction to Java and OO Concepts 16
Objects
 Individual ‘objects’ are created from the class design for each
actual thing.
 Objects are the basic runtime entities in an OO program.
 An object are an identifiable thing or individual containing
 The term "object" usually refers to instance. But it is often
used loosely, and may refer to a class or an instance
The basic concepts of OOP
13-04-2021 Introduction to Java and OO Concepts 17
 Encapsulation:
 means the wrapping up of data and methods into a single unit (a class). It also means
that the data inside a class is hidden from everything outside the class.
 The data can only be accessed by invoking the methods of the class. The internal
workings of the methods are of no concern to other classes in the program.
 Abstraction:
 refers to the way in which a class represents only the essential features of the set of
objects it models – a class does not include background or extra details that are not
relevant to the system.
 So a class is like a list of abstract attributes e.g. size, weight, cost, and the methods that
operate on those attributes e.g. change the cost, increase the weight.
The basic concepts of OOP
13-04-2021 Introduction to Java and OO Concepts 18
 Inheritance
 Inheritance is the way in which objects of one class get the properties of
objects of another class. This includes the data/ attributes and the methods.
 Polymorphism
 The word polymorphism means the ability to take more than one
form/structure. A particular operation/method may behave differently for
different number of inputs.
 polymorphism (literally "multiple-forms").
 Polymorphism is often called late- binding because the receiver object
binds the message to an appropriate implementation function (method in
Java terminology) at run-time when the message is sent rather than at
compile-time as functions are.
The basic concepts of OOP
13-04-2021 Introduction to Java and OO Concepts 19
 Reuse of existing classes and eliminate redundant code using inheritance.
 Encapsulation (hiding of data) helps with the building of more secure
programs
 There is a close link between objects in the real-world system and objects in
the program. Therefore, the structure of the system is more likely to be
meaningful to users.
 The work for a given project can be divided by class/object – making it easier
to split work up between a team of developers.
 OO systems can be easily upgraded from small to larger systems.
 The message passing technique for communication between objects makes it
easy to describe the interface of an OO system for other systems that need to
communicate with it.
 Software complexity can be easily managed....
 isolation of programmers (better team programming)
The Benefits of OOP
13-04-2021 Introduction to Java and OO Concepts 20

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
jaimefrozr
 

Was ist angesagt? (20)

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...
 
Core java course syllabus
Core java course syllabusCore java course syllabus
Core java course syllabus
 
Java programming course for beginners
Java programming course for beginnersJava programming course for beginners
Java programming course for beginners
 
Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVA
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
 
Introduction to JAVA
Introduction to JAVAIntroduction to JAVA
Introduction to JAVA
 
JAVA PROGRAMMING
JAVA PROGRAMMING JAVA PROGRAMMING
JAVA PROGRAMMING
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programming
 
1.introduction to java
1.introduction to java1.introduction to java
1.introduction to java
 
Core java online training
Core java online trainingCore java online training
Core java online training
 
Java basic-tutorial for beginners
Java basic-tutorial for beginners Java basic-tutorial for beginners
Java basic-tutorial for beginners
 
Core Java
Core JavaCore Java
Core Java
 
Java unit 1
Java unit 1Java unit 1
Java unit 1
 
Java seminar
Java seminarJava seminar
Java seminar
 
Java basic introduction
Java basic introductionJava basic introduction
Java basic introduction
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Core Java
Core JavaCore Java
Core Java
 
Introduction to java (revised)
Introduction to java (revised)Introduction to java (revised)
Introduction to java (revised)
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 

Ähnlich wie Chapter 1

Object Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesObject Oriented Programming All Unit Notes
Object Oriented Programming All Unit Notes
BalamuruganV28
 

Ähnlich wie Chapter 1 (20)

Java1
Java1Java1
Java1
 
Java
Java Java
Java
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
 
Java_presesntation.ppt
Java_presesntation.pptJava_presesntation.ppt
Java_presesntation.ppt
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
What is java?-Saurabh Upadhyay
What is java?-Saurabh UpadhyayWhat is java?-Saurabh Upadhyay
What is java?-Saurabh Upadhyay
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java Language
 
Object Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesObject Oriented Programming All Unit Notes
Object Oriented Programming All Unit Notes
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Presentation5
Presentation5Presentation5
Presentation5
 
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdfSulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
 
Java. converted (2)
Java. converted (2)Java. converted (2)
Java. converted (2)
 
Java notes jkuat it
Java notes jkuat itJava notes jkuat it
Java notes jkuat it
 
Java notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esectionJava notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esection
 
Spring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsSpring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggets
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruJava programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, Mysuru
 
OOP Java
OOP JavaOOP Java
OOP Java
 
Cs8392 oops 5 units notes
Cs8392 oops 5 units notes Cs8392 oops 5 units notes
Cs8392 oops 5 units notes
 

Mehr von siragezeynu (12)

2 programming with c# i
2 programming with c# i2 programming with c# i
2 programming with c# i
 
6 database
6 database 6 database
6 database
 
Recovered file 1
Recovered file 1Recovered file 1
Recovered file 1
 
Chapter one
Chapter oneChapter one
Chapter one
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Chapter 3i
Chapter 3iChapter 3i
Chapter 3i
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Lab4
Lab4Lab4
Lab4
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
6 chapter 6 record storage and primary file organization
6 chapter 6  record storage and primary file organization6 chapter 6  record storage and primary file organization
6 chapter 6 record storage and primary file organization
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Chapter 1

  • 1. Chapter 1 – Introduction to Java and OOP Concepts By Sirage Zeynu (M.Tech) Computing Science Debre Berhan University
  • 2. 13-04-2021 Introduction to Java and OO Concepts 2  Computer is a device that performs tasks based on given set of step- by-step instructions (procedures)  These set of procedures (step-by-step instructions) are called algorithms also called computer programs or software's.  Computing is a constantly changing our world and our environment.  The way in which we tell/give the set of procedures or programs to a computer are called programming languages. Examples are: C++, java, C#...  In order to write a program you need to go through several stages. These are 1. Type the text of the program into the computer 2. Translate the program text into a form the computer can use 3. Run the translated program Basics of programming
  • 3. 13-04-2021 Introduction to Java and OO Concepts 3  There are different types of programming languages based on the philosophy they use. Procedural Programming:  is a programming paradigm/modelling approach in which a list of step- by-step instructions telling a computer, what to do one after the other  linear order of execution from the first statement to the end. Example C, FORTRAN, Pascal, and Basic.  The procedural-oriented programs are made up of functions. Functions are less reusable  It is very difficult to copy a function from one program and reuse in another program because the function is likely to reference the global variables and other functions.  The procedural languages are not suitable of high-level abstraction for solving real life problems. Programming paradigms
  • 4. 13-04-2021 Introduction to Java and OO Concepts 4 Object oriented programming(OOP):  is a programming paradigm/modelling approach that represents concepts as "objects" that have ◦ data fields (attributes that describe the object) and ◦ Associated procedures known as methods/functions that operate or manage the data. ◦ OOP languages permit higher level of abstraction for solving real-life problems. ◦ The basic unit of OOP is a class, which encapsulates both the static properties and dynamic operations Examples : C++, Java, PHP, C#... Programming paradigms
  • 5. 13-04-2021 Introduction to Java and OO Concepts 5  Java programming language was originally developed by Sun Microsystems which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems' Java platform (Java 1.0 [J2SE]).  The latest release of the Java Standard Edition is Java SE 11.  With the advancement of Java and its widespread popularity, multiple configurations were built to suit various types of platforms.  For example: J2EE for Enterprise Applications, J2ME for Mobile Applications.  The new J2 versions were renamed as Java SE, Java EE, and Java ME respectively.  Java is guaranteed to be Write Once, Run Anywhere. Java Overview
  • 6. 13-04-2021 Introduction to Java and OO Concepts 6  Object Oriented: In Java, everything is an Object. Java can be easily extended since it is based on the Object model.  Simple: Java is designed to be easy to learn. If you understand the basic concept of OOP, Java would be easy to master.  Secure: With Java's secure feature, it enables to develop virus- free, tamper-free systems. Authentication techniques are based on public-key encryption  Architectural-neutral: Java compiler generates an architecture-neutral object file format, which makes the compiled code to be executable on many processors, with the presence of Java runtime system Features of Java programming language
  • 7. 13-04-2021 Introduction to Java and OO Concepts 7  Robust: Java makes an effort to eliminate error prone situations by emphasizing mainly on compile time error checking and runtime checking.  Multithreaded: With Java's multithreaded feature, it is possible to write programs that can do many tasks simultaneously. This design feature allows developers to construct smoothly running interactive applications.  High Performance: With the use of Just-In-Time compilers, Java enables high performance.  Dynamic: Java is considered to be more dynamic than C or C++ since it is designed to adapt to an evolving environment. Features of Java programming language
  • 8. 13-04-2021 Introduction to Java and OO Concepts 8  Distributed: Java is designed for the distributed environment of the internet.  Compiled and interpreted: java is both compiled and interpreted.  The Java compiler translates the program into an intermediate language called Java byte-codes.  Java byte-codes are platform-independent – this means they can be run on different operating systems (e.g. Windows, Linux, Mac...). There are different Java interpreters for different platforms. These interpreters parse and run each of the Java byte-code instructions to each machine code in which the machine can understand. The interpreters are usually called java Virtual Machine.  It is called a Virtual Machine because it is like a computer that does not physically exist  the JVM exists only within the memory of the computer. The Java byte-codes are like a set of machine code instructions for the JVM.  Compilation only needs to happen one time, whereas interpretation happens every time the program is executed Features of Java programming language
  • 9. 13-04-2021 Introduction to Java and OO Concepts 9  Java environment includes a large number of development tools and hundreds of classes & methods.  You can download the most up-to-date JDK and its documentation from java.sun.com/  The development tools are part of the system known as java development kit (JDK).  The set of classes and methods are part of the Java Standard Library(API), also known as Application Programming Interface(API). JAVA development Environment
  • 10. 13-04-2021 Introduction to Java and OO Concepts 10  Comes with a collection of tools that are used for developing and running java programs. They include ◦ javac --- java compiler ◦ java --- java interpreter ◦ jdb --- java debugger etc...  So, to develop java programs, we need to install jdk. And then we can use our own text editor to write java source code. Or instead of using our own text editor, another option we can use is installing other tools or APIs like Net-beans and Eclipse to easily code, compile and run java programs. Java Development Kit (JDK)
  • 11. 13-04-2021 Introduction to Java and OO Concepts 11  The Java API consists of many built-in classes and methods that we can use in our code. These classes and methods/functions are again grouped into a form packages. Package is a collection of related classes together. Some of the most commonly used packages are the following:  Language support package (java.lang) – classes required for implementing basic features of Java.  Utilities package (java.util) – classes that provide various utility functions such as date and time functions.  Input/Output package (java.io) – classes required for manipulation of input/output to/from programs  Networking Package (java.net) – classes used for communicating with other programs/PCs over networks and internet  Applet Package (java.applet) – classes that are used to create Java applets. Main Java API packages include:
  • 12. 13-04-2021 Introduction to Java and OO Concepts 12 Java programs normally go through five phases—edit, compile, load, verify and exe- cute.
  • 13. 13-04-2021 Introduction to Java and OO Concepts 13
  • 14. 13-04-2021 Introduction to Java and OO Concepts 14  Objects  classes  Data abstraction  encapsulation  Inheritance  Polymorphism  Dynamic (late) binding  Message communication The basic concepts of OO are
  • 15. 13-04-2021 Introduction to Java and OO Concepts 15 classes  A ‘class’ is a software design which describes the general properties of something which the software is modelling.  A class is the definition of a set of objects or a class is the design of an object. A class models a static view of objects which exist in the system users' world.  A class can be visualized as a three-compartment box, as illustrated:  Name (or identity): identifies the class.  Variables (or attribute, state, field): contains the static attributes of the class.  Methods (or behaviours, function, operation): contains the dynamic behaviors of the class. The basic concepts of OOP
  • 16. 13-04-2021 Introduction to Java and OO Concepts 16 Objects  Individual ‘objects’ are created from the class design for each actual thing.  Objects are the basic runtime entities in an OO program.  An object are an identifiable thing or individual containing  The term "object" usually refers to instance. But it is often used loosely, and may refer to a class or an instance The basic concepts of OOP
  • 17. 13-04-2021 Introduction to Java and OO Concepts 17  Encapsulation:  means the wrapping up of data and methods into a single unit (a class). It also means that the data inside a class is hidden from everything outside the class.  The data can only be accessed by invoking the methods of the class. The internal workings of the methods are of no concern to other classes in the program.  Abstraction:  refers to the way in which a class represents only the essential features of the set of objects it models – a class does not include background or extra details that are not relevant to the system.  So a class is like a list of abstract attributes e.g. size, weight, cost, and the methods that operate on those attributes e.g. change the cost, increase the weight. The basic concepts of OOP
  • 18. 13-04-2021 Introduction to Java and OO Concepts 18  Inheritance  Inheritance is the way in which objects of one class get the properties of objects of another class. This includes the data/ attributes and the methods.  Polymorphism  The word polymorphism means the ability to take more than one form/structure. A particular operation/method may behave differently for different number of inputs.  polymorphism (literally "multiple-forms").  Polymorphism is often called late- binding because the receiver object binds the message to an appropriate implementation function (method in Java terminology) at run-time when the message is sent rather than at compile-time as functions are. The basic concepts of OOP
  • 19. 13-04-2021 Introduction to Java and OO Concepts 19  Reuse of existing classes and eliminate redundant code using inheritance.  Encapsulation (hiding of data) helps with the building of more secure programs  There is a close link between objects in the real-world system and objects in the program. Therefore, the structure of the system is more likely to be meaningful to users.  The work for a given project can be divided by class/object – making it easier to split work up between a team of developers.  OO systems can be easily upgraded from small to larger systems.  The message passing technique for communication between objects makes it easy to describe the interface of an OO system for other systems that need to communicate with it.  Software complexity can be easily managed....  isolation of programmers (better team programming) The Benefits of OOP
  • 20. 13-04-2021 Introduction to Java and OO Concepts 20