Uploaded by Md. Moshiur Rahman

Introduction to OOP

advertisement
Introduction to
Object Oriented Programming
Object Oriented Programming
Object means a real-world entity such as a pen, chair, table, computer,
watch, etc. Object-Oriented Programming is a methodology or
paradigm to design a program using classes and objects. It simplifies
software development and maintenance by providing some concepts:
• Object
• Class
• Inheritance
• Polymorphism
• Abstraction
• Encapsulation
Difference between OOP and SPL
The main difference between structured and object oriented
programming is that structured programming allows developing a
program using a set of modules or functions, while object oriented
programming allows constructing a program using a set of objects and
their interactions
• Main Focus
Furthermore, structured programming focuses on dividing the program
into a set of functions in which each function works as a subprogram
while object oriented programming focuses on representing a program
using a set of objects which encapsulates data and object.
• Modification
Moreover, it is difficult to modify the structured programs while it is easier to
modify the Object Oriented programs.
• Communication
In structured programming, the main method communicates with the
functions by calling those functions in the main program whereas, in object
oriented programming, the objects communicate with each other by passing
messages. Hence, this is an important difference between structured and
object oriented programming.
• Access Specifiers
There are no access specifiers in structured programming while there are
access specifiers such as private, public and protected in Object Oriented
Programming. Thus, this is also an important difference between structured
and object oriented programming.
• Security
Besides, data is not secure in structured programming, but it is secure
in object oriented programming.
• Code Reusability
Also, it is difficult to reuse code in structured programming, whereas it
is easier to reuse code in object oriented programming.
Object
Object Definitions:
• An object is a real-world entity.
• An object is a runtime entity.
• The object is an entity which has state and behavior.
• The object is an instance of a class.
What is an object in Java
An entity that has state and behavior is known as an object e.g., chair, bike,
marker, pen, table, car, etc. It can be physical or logical (tangible and
intangible). The example of an intangible object is the banking system.
An object has three characteristics:
• State: represents the data (value) of an object.
• Behavior: represents the behavior (functionality) of an object such as
deposit, withdraw, etc.
• Identity: An object identity is typically implemented via a unique ID. The
value of the ID is not visible to the external user. However, it is used
internally by the JVM to identify each object uniquely.
JVM (Java Virtual Machine) Architecture
• JVM (Java Virtual Machine) is an abstract machine. It is a specification
that provides runtime environment in which java bytecode can be
executed.
• JVMs are available for many hardware and software platforms (i.e.
JVM is platform dependent).
The JVM performs following operation:
• Loads code
• Verifies code
• Executes code
• Provides runtime environment
JVM Architecture
Download