Introduction To Object Oriented Programming Object Oriented Programming
Introduction To Object Oriented Programming Object Oriented Programming
i) Objects
These are basic run-time entities in an object oriented system they may represent a person, place,
bank account a table of data or any item that the program has to handle. Objects also represent
user defined data such as vectors, time and lists.
The concept of object is used simplify the representation of complex real world structures as
software structures in the computer.
Objects enable abstraction of the real world and structural representation in the computer.
ii) Classes
A class is a collection of objects of similar type classes can be concretely defined example
apples, banana, and mangos are members of a class fruit. Classes are user-defined data types and
behave like the built-in types of a programming language.
Types of classes
Abstract class
Concrete class
Active Class
iii) Abstraction
A concept important for simplification of representation of complex structures
Representation of complex structure by simpler structure that hide the complex details
In computer science abstraction has enabled the development of various levels of programming
languages that enable simplify the definition of the program and data structures that would be
difficult to do with the natural language of the computer.
This has simplified the development of the large programs that provide real world solutions –
programs that would be difficult to implement with the machine language
iv) Encapsulation
The containment or packaging of data and the functions that use the data in a program module.
Encapsulation protects the data from modification by functions external to the object.
This is implemented by definition of abstract structure referred to as class that represents the type
of object.
Facilitates information hiding which is an important characteristic that enables create reliable
programs
v) Inheritance
Is the process by which objects of one class acquire the properties of objects of
another class.
A concept used in object oriented programming to describe the relationship between
types of objects where one object is a sub type of another.
Inheritance is one of the approach to employing reuse in programming.
Reuse by inheritance enables to take an existing type of object, clone it and then make
additions and modifications to the clone.
Types of inheritance
– Single inheritance - A sub type of an object inherits from only one super type.
– Multiple inheritance - A sub type of an object inherits from two or more super
types.
– Repeated inheritance - A special multiple inheritance where the super types of a
subtype inherit from another super type.
– Selective inheritance - Limited inheritance of a subtype from its super type.
Restricting access to some details in the super type
vi) Polymorphism
Polymorphism is a Greek term which means ability to take more than one form. An operation
may exhibit different behaviors in different instances. The behavior depends upon the types of
data used in operation.
Types of polymorphism
Overloading- This is changing the implementation of a method inherited from a parent class. The
name, arguments and the return type remain the same but the action differs
Overriding- This means using the same name for different methods in a class.
vii) Message passing
This refers to the communication between objects. Objects communicate with one another by
sending and receiving information.