Published on

This slideshow is the basics of Object Oriented Programming Concepts made for freshers.

Published in: Self Improvement
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. OOP Concepts Created by - Om Vikram Thapa
  2. 2. OOP vs. POP <ul><ul><li>Emphasis is on data. </li></ul></ul><ul><ul><li>Divides code into logical chunks individuals of a team can be experts in, and outsiders can understand via interfaces </li></ul></ul><ul><ul><li>Supports code evolution: internals can always be re-written as long as interface stays the same. </li></ul></ul><ul><ul><li>Data security. </li></ul></ul><ul><li>Emphasis is on procedures. </li></ul><ul><li>This programming technique can only be used in a very small program. </li></ul><ul><li>if the same statement sequence is needed at different locations, the sequence must be copied. If an error needed to be modified, every copy needs to be modified. </li></ul>
  3. 3. Procedure Program view Main Program Data Procedure 1 Procedure 2 Procedure 3
  4. 4. OOP Program view Data Object 3 Data 3 + Procedures 3 Object 2 Data 2 + Procedures 2 Object 4 Data 4 + Procedures 4 Object 1 Data 1 +Procedures 1
  5. 5. Main OOP Concepts: <ul><li>Object </li></ul><ul><li>Class </li></ul><ul><li>Abstraction </li></ul><ul><li>Encapsulation </li></ul><ul><li>Inheritance </li></ul><ul><li>Polymorphism </li></ul>
  6. 6. Objects and Class <ul><li>An object represents something with which we can interact in a program </li></ul><ul><li>A class represents a concept, and an object represents the embodiment of a class </li></ul><ul><ul><li>A class is a blueprint for an object. </li></ul></ul><ul><li>A class can be used to create multiple objects </li></ul><ul><li>A program models a world of interacting objects. </li></ul><ul><li>Objects create other objects and “send messages” to each other. </li></ul><ul><li>Each object belongs to a class; a class defines properties of its objects. The data type of an object is its class. </li></ul>
  7. 7. Abstraction <ul><li>One of the chief advantages of object-oriented programming is the idea that programmers can essentially focus on the “big picture” and ignore specific details regarding the inner-workings of an object. This concept is called abstraction . </li></ul>
  8. 8. Encapsulation <ul><li>Abstraction in OOP is closely related to a concept called encapsulation . </li></ul><ul><li>Data and the ways to get at that data are wrapped in a single package, a class. The only way to access such data is through that package. This idea translates to information hiding. </li></ul>
  9. 9. Inheritance <ul><li>Another of the main tenets of OOP is inheritance . Inheritance allows programmers to create new classes from existing ones. </li></ul><ul><li>A child class inherits its properties and attributes from its parents, which programmers can change. </li></ul>
  10. 10. Polymorphism <ul><li>Polymorphism describes how programmers write methods to do some general purpose function. </li></ul><ul><li>Different objects might perform polymorphic methods differently. </li></ul><ul><li>The ability of objects to respond differently to the same message or function call. </li></ul>
  11. 11. Examples <ul><li>Object legislates how its data may be accessed ( encapsulation ) </li></ul><ul><ul><li>Once you have created an ADT for complex numbers, say Complex, you can use it in the same way like well-known data types such as integers. </li></ul></ul><ul><ul><li>Encapsulation provides a way to protect data from accidental corruption. </li></ul></ul><ul><li>One class may be a special case of another ( inheritance ) </li></ul><ul><ul><li>Rectangle is like a square, plus a second (possibly) distinct value </li></ul></ul><ul><ul><li>Colored-Rectangle is like a rectangle, plus the concept of color </li></ul></ul><ul><li>Different classes in a hierarchy behave correctly( polymorphism ) </li></ul><ul><ul><li>shape.getArea(a,b) = len*wid, if shape is a rectangle </li></ul></ul><ul><ul><li>shape.getArea(a) = PI*r2, if shape is a circle </li></ul></ul>