You are on page 1of 6

DEFINITIONS: OOPS: Object oriented programming is a programming methodology used to solve and develop complex problems by using oops

principles encapsulation, inheritance and polymorphism. BASIC ELEMENTS OF OOPs: The basic elements of oops are: Class Object Encapsulation Inheritance Polymorphism Data abstraction and data encapsulation Message passing OBJECT:

The logical thing class is called by the real thing called as object. Instance of the class are called object

Objects are the basic run-time entities in an object-oriented system. They may represent a person, a place, a bank account, a table of data or any item that the program has to handle. They may also represent user-defined data such as vectors, time and lists.
objects Triangle Data(Attributes) Number of sides Length side a Length side b Length side c Border colour Fill colour Make Frame size Wheel size Gears Material Functions Draw Fill colour Area Move

Cycle

Shift Move Repair Assemble

While Representing Objects in computer it occupies some memory space and have an associated Address. During execution objects can Exchange Information. DATA ABSTRACTION: Abstraction is defined as a grouping of essential detail and ignoring other details. Data abstraction is defined as a named collection of data that describes a data object in a class. For Example Cost, size, weight and colour are all named collection of data that describes the object chair in the class furniture. Class is also called abstract data type because classes use the principle of data abstraction.

DATA ENCAPSULATION: The wrapping up of data and function into a single unit (called class) is known as encapsulation. Data encapsulation is the most striking feature of a class. The data is not accessible to the outside world, and only those functions which are wrapped in the class can access it. These function provide the interface between the objects data and the program. Data from direct access by the program is called data hiding or information hiding. Encapsulation is a technique used to protect the information in an object from other objects. CLASS:

Class is place where data and functions that acts on that are declared and defined. The binding of data and function s in a single entity is called as class. Class is a template for an object

A class is defined as a collection of objects with same type of data and functions. The entire set of data and code of an object can be made a user-defined data type with the help of a class. Objects are variables of the type class. Once a class has been defined, we can create any number of objects belonging to that class. Each object is associated with the data of type class with which they are created. A class is thus a collection of objects of similar type. For example, mango, apple and orange are members of the class fruit. Classes are user-defined data types and behave like the built-in types of a programming language. The syntax used to create an object is no different than the syntax used to create an integer object in C. The general form is
class class_name declaration of data ----------------------------------------------------------definition of functions --------------------------------------------------------end class

Where class keyword, Class_name - user defined name

Example: The collection of objects such as table, chair, etc can be grouped as a class named as furniture as shown below.
Class:furniture Cost Size Weight colour Buy Shell Shifted jrepair

Object:chair Cost:200 Size:2 feet Weight:10 Colour:B Buy Shell Shifted repair

Object:table Cost:300 Size:3 feet Weight:20 Colour:R Buy Shell Shifted repair

. INHERITANCE One object acquires the properties of another object or existing object. Reusability of existing or pre-written code Inheritance is the process by which objects of one class acquire the properties of objects of another class. It supports the concept of hierarchical classification. The concept of inheritance provides the idea of reusability. This means that we can add additional features to an existing class without modifying it. This is possible by deriving a new class from the existing one. The new class will have the combined features of both the classes. The Existing classes are called base classes and the inherited classes are derived classes. The structure of inheritance is like a tree structure. Example: Employee Teaching Non-Teaching

H.O.D

Lecturer

principal

Manager

Assistants

HOD is a derived class of teaching which is a derived class of employee. So it contains all attributes and functions of teaching and employee plus its own attributes and functions. POLYMORPHISM: Polymorphism is the capability of a set of objects behaves in similar but independent ways. One interface with different type of forms.

Polymorphism is another important OOS concept. Polymorphism a Greek term means the 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 the operation. A single function name can be used to handle different number and different types of arguments. This is something similar to a particular word having several different meanings depending on the context. Using a single function name to perform different types of tasks is known as function overloading. Example:
Image Colour Border Thickness Move Rotate Display

Circle ----------------------------Center diameter --------------display

Polygon ----------------------Number of sides --------------display

Box ------------------------Length of sides -------------display

In the above classes, the function display is defined in all classes. But the operation of the function display is different. In circle class the display function draws a circle with the given centre and diameter. In polygon class the display function draws a polygon with the given no of sides. In box class the display function draws the box with the given length of sides.

DYNAMIC BINDING: Binding is defined as the connection between the function call and its corresponding program code to be executed. There are two types of binding. They are: 1. Static Binding- The Binding Occurs during compilation time . 2. Dynamic Binding: The binding occurs during run time this is also called late binding. MESSAGE PASSING: An object-oriented program consists of a set of objects that communicate with each other. The process of programming in an object-oriented language, therefore, involves the following basic steps: (1) Creating classes that define objects and their behavior (2) Creating objects from class definitions (3) Establishing communication among objects Object_name.message(information);

Where object_name declared object name Message- name of the function to be executed Information- data to be send Example: Circle.display(); In this, display is a message sent by the object circle to execute the function display ().

BENEFITS OF OOPS: 1. Simplicity: Software objects model real world objects, so the complexity is reduced and the program Structure is very clear. 2. Modularity: Each object forms a separate entity whose internal workings are decoupled from other parts of the system. 3. Modifiability: It is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods.

4. Extensibility: Adding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones. 5. Maintainability: Objects can be maintained separately, making locating and fixing problems easier. 6. Re-usability: Objects can be reused in different programs. 7. Through inheritance, we can eliminate redundant code and extend the use of existing classes we can build programs from the standard working the modules that communicate with one another, rather than having to start writing the code from scratch. This leads to saving of development time and higher productivity. 8. The principle of data hiding helps the programmer to build secure programs that cannot be invaded by the code in other parts of the program. 9. It is possible to have multiple instances of an object to coexist without any interference. 10. It is possible to map objects in the problem domain to those in the program 11. It is easy to partition the work in a project based on objects. 12. The data centered design approach enables us to capture more details of a model in implement able form. 13. Object oriented systems can be easily upgraded from small to large system. 14. Message passing techniques for communication between objects makes the interface.

You might also like