OOP-Chapter 1-Introduction - To - Object - Oriented - V1.0
OOP-Chapter 1-Introduction - To - Object - Oriented - V1.0
INTRODUCTION
TO
OBJECT-ORIENTED PROGRAMMING
(OOP)
11/18/2021
Contents
1. Overview of OOP
2. Java, JVM and Byte Code
3. Basic Concepts of OOP
Classes
Objects
Members
Class member visibility
11/18/2021
Overview of OOP
Object-oriented programming (OOP) is a
programming paradigm that uses “Objects “and
their interactions to design applications.
OOP focuses on the objects that developers want to
manipulate rather than the logic required to
manipulate them.
This approach to programming is well-suited for
programs that are large, complex and actively
updated or maintained.
The first step in OOP is to collect all of the objects
a programmer wants to manipulate and identify
how they relate to each other (Data Modeling).
Examples of an object can range from physical entities,
such as a human being who is described by properties
like name and address, down to small computer
programs, such as Widgets.
Once an object is known, it is labeled with
a class of objects that defines the kind of data it
contains and any logic sequences that can
manipulate it.
Each distinct logic sequence is known as a method.
Objects can communicate with well-defined
interfaces called messages.
Basic principles of OOP
Basic principles of OOP
OOP contains the following fundamentals principles
Abstraction
Allows us to consider complex ideas while ignoring
irrelevant detail that would confuse us.
It is the process of selecting data from a larger pool to show
only the relevant details to the object.
This concept helps developers more easily make changes
and additions over time.
Example
Suppose you want to create a dating application and you are
asked to collect all the information about your users.
Example: Abstraction
Dating application
Identifying an Object?
You can also think of other non physical things as objects:-
such as a bank account
A bank account is not something that can be physically touched
but intellectually we can consider a bank account to be an object.
OOP is a method of programming that involves the
creation of intellectuals objects that model a business
problem we are trying to solve.
In creating an OO program we define the properties of a
class of objects and then create individual objects from the
class
11/18/2021
Benefits of OOP Approach
15
Better abstraction
Modeling information and behavior together
Better maintainability
More comprehensible, less fragile software
Better usability
Classes as encapsulated components that can be used
in other systems
11/18/2021
Contents
1. Overview of OOP
2. Java, Byte Code and JVM
3. Basic Concepts of OOP
Classes
Objects
Members
Class member visibility
11/18/2021
Java, JVM and Byte code
17
Java
Java is a programming language and a platform.
Java is a high level, robust, object-oriented and secure
programming language.
Java was developed by Sun Microsystems (which is
now the subsidiary of Oracle) in the year 1995.
James Gosling is known as the father of Java.
11/18/2021
18
11/18/2021
19
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, it 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.
11/18/2021
22
Platform Independent
Unlike many other programming languages including C and
C++, when Java is compiled, it is not compiled into
platform specific machine, rather into platform-independent
byte code.
This byte code is distributed over the web and interpreted by the
Virtual Machine (JVM) on whichever platform it is being run on.
Robust
Java makes an effort to eliminate error-prone situations by
emphasizing mainly on compile time error checking and
runtime checking.
11/18/2021
23
Portable
Being architecture-neutral and having no implementation
dependent aspects of the specification makes Java
portable.
The compiler in Java is written in ANSI C with a clean
portability boundary, which is a POSIX subset.
Architecture-neutral
Java compiler generates an architecture-neutral object file
format, which makes the compiled code executable on
many processors, with the presence of Java runtime
system.
11/18/2021
24
Dynamic
Java is considered to be more dynamic than C or C++
since it is designed to adapt to an evolving environment.
Java programs can carry an extensive amount of run-time
information that can be used to verify and resolve accesses to
objects at run-time.
Interpreted
Java byte code is translated on the fly to native machine
instructions and is not stored anywhere.
The development process is more rapid and analytical since the
linking is an incremental and light-weight process.
11/18/2021
25
High Performance
With the use of Just-In-Time compilers, Java enables high
performance.
Multithreaded
With Java's multithreaded feature it is possible to write
programs that can perform many tasks simultaneously.
This design feature allows the developers to construct interactive
applications that can run smoothly.
Distributed
Java is designed for the distributed environment of the
internet.
11/18/2021
Java bytcode
26
11/18/2021
27 11/18/2021
Java Virtual Machine(JVM)
28
11/18/2021
29
What is JVM?
1. A specification where working of Java Virtual Machine
is specified.
But implementation provider is independent to choose the
algorithm. Its implementation has been provided by Oracle
and other companies.
2. An implementation Its implementation is known as
JRE (Java Runtime Environment).
3. Runtime Instance Whenever you write java command
on the command prompt to run the java class, an
instance of JVM is created.
11/18/2021
30
What it does?
The JVM performs following operation:
Loads code
Verifies code
Executes code
Provides runtime environment
JVM provides definitions for the:
Memory area
Class file format
Register set
Garbage-collected heap
Fatal error reporting etc
11/18/2021
31 11/18/2021
Contents
1. Overview of OOP
2. Java, JVM and Byte Code
3. Basic Concepts of OOP
Objects
Classes
Members
Class member visibility
11/18/2021
Basic Concepts of OOP
33
What is Object?
Object: A single software unit that combines
attributes and methods. It represents an entity in
the real world.
Attribute: A "characteristic" of an object; like a
variable associated with a kind of object.
Method: A "behavior" of an object; like a function
associated with a kind of object.
11/18/2021
34
Example
Dog
Attributes:breed, color, hungry, tired, etc.
Behaviors: eating, sleeping, etc.
Bank Account
Attributes:account number, owner, balance
Behaviors: withdraw, deposit
11/18/2021
What is Classes?
35
objects.
A class can be thought of as a template used to
number: 054
When the program runs there
balance: $19
will be many instances of the
Instance #2
account class. number: 712
balance: $941
Methods can only be invoked .
Members of the Class
39
11/18/2021
Members of the class
40
11/18/2021
41
11/18/2021
Class Members Visibility
42
11/18/2021
43
Questions?
11/18/2021
44
Thank You
11/18/2021