Submitted to:
Assistant Professor
Department of Computer Science &
Engineering
Welcome To Our Presentation
Submitted By:
What Is OOP ?
OOP in full form Object Oriented Programming is an
Engineering approach for building software systems.
Main concepts of OOP are: 1. Classes
2. Objects
Object-oriented programs
• Consist of a group of co-operating objects
• Objects exchange messages, for the purpose of achieving a common
objective
• Implemented in object-oriented languages
•Each object belongs to a class
• A class defines properties of its objects
• The data type of an object is its class
What Are Objects?
•Software objects model real-world objects or
abstract concepts
• Example: dog, bicycle.
•Real-world objects have states and behaviors
• Dogs' states : Name, Color, Breed, Hungry
• Dogs' behaviors : Barking, Fetching, Sleeping
That is why we can say that every object should have
states and behaviors .
 checks
 people
 shopping list
 numbers
 characters
 arrays
Things in the real
world
Things in the computer
world
Classes
•Classes provide the structure for objects
• Define their prototype
•Classes define:
• Set of attributes
• Also called state
• Represented by variables and properties
• Behavior
• Represented by methods
•A class defines the methods and types of data associated with an
object
Access Modifier
– public – access is not restricted
– private – access is restricted to the containing type
– protected – access is limited to the containing type and types
derived from it
– protected – access is limited to the current assembly or type
s derived from the containing class
Messages
•What is a message in OOP?
• A request for an object to perform one of its operations (methods)
•All communication between objects is done via messages
Inheritance
•A class can extend another class, inheriting all its data
members and methods
• The child class can redefine some of the parent class's members
and methods and/or add its own
•A class can implement an interface, implementing all the
specified methods
•Inheritance implements the “is a” relationship between
objects
Inheritance
Diagram:
Person
+Name: String
+Address: String
Employee
+Company: String
+Salary: double
Student
+School: String
Superclass
SubclassSubclass
Inheritance in Java
•In Java, a subclass can extend only one superclass
•In Java, a sub interface can extend one super
interface
•In Java, a class can implement several interfaces
• This is Java’s form of multiple inheritance
Over-Loading
Object-Oriented Programming also provides a
facility to extend the meaning of available
functions and operators. Assigning an extra
meaning to an existing operator or a function
is known as Over-Loading.
Abstraction
•An abstract class can have code for some of its metho
ds
• Other methods are declared abstract and left with no code
•An interface only lists methods but does not have any
code
•A concrete class may extend an abstract class and/or
implement one or several interfaces, supplying the cod
e for all the methods
• Abstraction means ignoring irrelevant features, properties, or
functions and emphasizing the relevant ones...
• ... relevant to the given project
• Abstraction = managing complexity
“Relevant” to what?
Inheritance
 Structures cannot be inherited
 Only multiple interfaces can be implemented
 Instance and static constructors are not inherited
 Inheritance is transitive relation
 If C is derived from B, and B is derived from A, then C inherits A as well
Benefits of Interface
•Inheritance plays a dual role:
• A subclass reuses the code from the superclass
• A subclass inherits the data type of the superclass
or interface as its own secondary type
Polymorphism
•Ability to take more than one form
• A class can be used through its parent class's interface
• A subclass may override the implementation of an operation it
inherits from a superclass Polymorphism allows abstract
operations to be defined and used
• Abstract operations are defined in the base class's interface
and implemented in the subclasses.
• Why use an object as a more generic type?
• To perform abstract operations
• To mix different related types in the same collection
• To pass it to a method that expects a parameter of a
more generic type
• To declare a more generic field (specially in an abstract
class) which will be initialized and “specialized” later
THANK YOU

Object oriented programming

  • 1.
    Submitted to: Assistant Professor Departmentof Computer Science & Engineering Welcome To Our Presentation
  • 2.
  • 3.
    What Is OOP? OOP in full form Object Oriented Programming is an Engineering approach for building software systems. Main concepts of OOP are: 1. Classes 2. Objects
  • 4.
    Object-oriented programs • Consistof a group of co-operating objects • Objects exchange messages, for the purpose of achieving a common objective • Implemented in object-oriented languages •Each object belongs to a class • A class defines properties of its objects • The data type of an object is its class
  • 5.
    What Are Objects? •Softwareobjects model real-world objects or abstract concepts • Example: dog, bicycle. •Real-world objects have states and behaviors • Dogs' states : Name, Color, Breed, Hungry • Dogs' behaviors : Barking, Fetching, Sleeping That is why we can say that every object should have states and behaviors .
  • 6.
     checks  people shopping list  numbers  characters  arrays Things in the real world Things in the computer world
  • 7.
    Classes •Classes provide thestructure for objects • Define their prototype •Classes define: • Set of attributes • Also called state • Represented by variables and properties • Behavior • Represented by methods •A class defines the methods and types of data associated with an object
  • 8.
    Access Modifier – public– access is not restricted – private – access is restricted to the containing type – protected – access is limited to the containing type and types derived from it – protected – access is limited to the current assembly or type s derived from the containing class
  • 9.
    Messages •What is amessage in OOP? • A request for an object to perform one of its operations (methods) •All communication between objects is done via messages
  • 10.
    Inheritance •A class canextend another class, inheriting all its data members and methods • The child class can redefine some of the parent class's members and methods and/or add its own •A class can implement an interface, implementing all the specified methods •Inheritance implements the “is a” relationship between objects
  • 11.
    Inheritance Diagram: Person +Name: String +Address: String Employee +Company:String +Salary: double Student +School: String Superclass SubclassSubclass
  • 12.
    Inheritance in Java •InJava, a subclass can extend only one superclass •In Java, a sub interface can extend one super interface •In Java, a class can implement several interfaces • This is Java’s form of multiple inheritance
  • 13.
    Over-Loading Object-Oriented Programming alsoprovides a facility to extend the meaning of available functions and operators. Assigning an extra meaning to an existing operator or a function is known as Over-Loading.
  • 14.
    Abstraction •An abstract classcan have code for some of its metho ds • Other methods are declared abstract and left with no code •An interface only lists methods but does not have any code •A concrete class may extend an abstract class and/or implement one or several interfaces, supplying the cod e for all the methods
  • 15.
    • Abstraction meansignoring irrelevant features, properties, or functions and emphasizing the relevant ones... • ... relevant to the given project • Abstraction = managing complexity “Relevant” to what?
  • 16.
    Inheritance  Structures cannotbe inherited  Only multiple interfaces can be implemented  Instance and static constructors are not inherited  Inheritance is transitive relation  If C is derived from B, and B is derived from A, then C inherits A as well
  • 17.
    Benefits of Interface •Inheritanceplays a dual role: • A subclass reuses the code from the superclass • A subclass inherits the data type of the superclass or interface as its own secondary type
  • 18.
    Polymorphism •Ability to takemore than one form • A class can be used through its parent class's interface • A subclass may override the implementation of an operation it inherits from a superclass Polymorphism allows abstract operations to be defined and used • Abstract operations are defined in the base class's interface and implemented in the subclasses.
  • 19.
    • Why usean object as a more generic type? • To perform abstract operations • To mix different related types in the same collection • To pass it to a method that expects a parameter of a more generic type • To declare a more generic field (specially in an abstract class) which will be initialized and “specialized” later
  • 20.