KEMBAR78
OOPS (Object Oriented Programming System) CONCEPTS | PPTX
OOPS CONCEPTS
Introduction
• Object oriented programming is a paradigm that provides many concepts such
as inheritance, polymorphism, abstraction, encapsulation.
• Simula is considered as the first object-oriented programming language
• The main aim of oops is to bind together the data and the functions that
operate on them so that no other part of the code can access this data except
that functions.
OOPS Concepts are
• Class
• Object
• Method and method passing
• Pillars of OOPs
• Abstraction
• Encapsulation
• Inheritance
• polymorphism
CLASS
• A class is a user defined blueprint or prototype from which objects are
created.
• It represents the set of properties or methods that are common to all objects of
one type.
• In general class declarations can include these components, in order
• Modifier
• Class name
• Body
OBJECT
• Object is a basic unit of object oriented programming and represents the real
life entities
• A typical java program creates many objects, which as you know, interact by
invoking methods.
• An object consist of
• State
• Behaviour
• Identity
• method
PILLARS OF OOP’s
• ABSTRACTION
• ENCAPSULATION
• POLYMORPHISM
• INHERITANCE
ABSTRACTION
• Data abstraction is the property by virtue of which only the essential details
are displayed to the user.
• Data abstraction may also be defined as the process of identifying only the
required characteristics of an object ignoring the irrelevant details.
• The properties and behaviours of an object differentiate it from other object
of similar type and also help in classifying/grouping objects.
• In java, abstraction is achieved by interfaces and abstract class, we can
achieve 100% abstraction using interfaces.
ENCAPSULATION
• It is defined as the wrapping up of data under a single unit
• It is the mechanism that binds together code and the data it manipulates
• It is a protective shield that prevents the data from being accessed by the code
outside this shield
• As in encapsulation, the data in a class is hidden from other classes, so it is
also known as data hiding.
• Encapsulation can be achieved by declaring all the variable in the class as
private and writing public methods in the class to set and get the values of
variables.
POLYMORPHISM
• The word polymorphism means having many forms
• In simple words, we can define polymorphism as the ability of a message to
be displayed in more than one form.
• Polymorphism allows us to perform a single action in different ways, in other
words, polymorphism allows you to define one interface and have multiple
implementations.
• The word “poly” means many and “morph” means forms, so it means many
forms
TYPES OF POLYMORPHISM
• In java polymorphism is mainly divided into two types.
• Compile-time polymorphism
• Run-time polymorphism
Compile-time polymorphism
• It is also known as static polymorphism.
• This type of polymorphism is a achieved by function overloading or
operator overloading
(java doesn’t support the operator overloading)
Method overloading: when there are multiple functions with the same name
but different parameters then these functions are said to be overloaded
Functions can be overloaded by change in the number of arguments
or/and a change in the type of arguments
Run-time polymorphism
• It is also known as Dynamic method dispatch
• It is a process in which a function call to the overridden method is resolved at
runtime
• This type of polymorphism is achieved by method overriding
Method overriding: on the other hand, occurs when a derived class has a
definition for one of the member functions of the base class, the base function is
said to be overridden.
INHERITANCE
• Inheritance in java is “ a mechanism in which one object acquire all the
properties and behaviours of a parent class object “
• It is an important part of oops
• The idea behind inheritance in java is that you can create new classes that are built
upon existing classes
• When you inherit from an existing class, you can reuse methods and fields of
parent class
• Inheritance represents the IS-A Relationship which is also known as a parent-child
relationship
USES OF INHERITANCE
• For method overriding
• For code reusability
TERMS USED IN INHERITANCE
• CLASS: A class is a group of objects which have common properties
it is a template or blueprint from which objects are created
• SUB CLASS/CHILD CLASS: Subclass is a class which inherits the other
class
it is also called derived class, extend class
• SUPER CLASS/ PARENT CLASS : Super class is the class from where a
subclass inherits the features.
it is also called a base class or a parent classs.
SYNTAX
Class Subclass_name extends Superclass_name
{
//Method and Fields
}
The extend keyword indicates that you are making a new class
that derives from an existing class.
TYPES OF INHERITANCE
• On the basis of class there can be three types of inheritance in java. Single,
Multilevel and Hierarchical.
• In java programming, multiple and hybrid inheritance is supported through
interface only.
• When one class inherits multiple classes it is known as multiple inheritance.
• SINGLE INHERITANCE: When a class inherits another class, it is known as
a single inheritance
• MULTILEVEL INHERITANCE: When there is a chain of inheritance it is
known as multilevel inheritance
• HIERARCHICAL INHERITANCE: When two or more classes inherits a
single class it is known as hierarchical inheritance
WHY MULTIPLE INHERITANCE IS NOT
SUPPORTED IN JAVA?
• To reduce the complexity and simplify the language, multiple inheritance is
not supported in java
• Consider, a scenario where A,B and C are three classes. The C class inherits A
and B classes
• If A and B classes have the same method and you call it from child class
object, there will be ambiguity to call the method of A or B class
• Since compile-time errors are better than runtime errors.
THANKING YOU
BY
HARIKUMAR M

OOPS (Object Oriented Programming System) CONCEPTS

  • 1.
  • 2.
    Introduction • Object orientedprogramming is a paradigm that provides many concepts such as inheritance, polymorphism, abstraction, encapsulation. • Simula is considered as the first object-oriented programming language • The main aim of oops is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that functions.
  • 3.
    OOPS Concepts are •Class • Object • Method and method passing • Pillars of OOPs • Abstraction • Encapsulation • Inheritance • polymorphism
  • 4.
    CLASS • A classis a user defined blueprint or prototype from which objects are created. • It represents the set of properties or methods that are common to all objects of one type. • In general class declarations can include these components, in order • Modifier • Class name • Body
  • 5.
    OBJECT • Object isa basic unit of object oriented programming and represents the real life entities • A typical java program creates many objects, which as you know, interact by invoking methods. • An object consist of • State • Behaviour • Identity • method
  • 6.
    PILLARS OF OOP’s •ABSTRACTION • ENCAPSULATION • POLYMORPHISM • INHERITANCE
  • 7.
    ABSTRACTION • Data abstractionis the property by virtue of which only the essential details are displayed to the user. • Data abstraction may also be defined as the process of identifying only the required characteristics of an object ignoring the irrelevant details. • The properties and behaviours of an object differentiate it from other object of similar type and also help in classifying/grouping objects. • In java, abstraction is achieved by interfaces and abstract class, we can achieve 100% abstraction using interfaces.
  • 8.
    ENCAPSULATION • It isdefined as the wrapping up of data under a single unit • It is the mechanism that binds together code and the data it manipulates • It is a protective shield that prevents the data from being accessed by the code outside this shield • As in encapsulation, the data in a class is hidden from other classes, so it is also known as data hiding. • Encapsulation can be achieved by declaring all the variable in the class as private and writing public methods in the class to set and get the values of variables.
  • 9.
    POLYMORPHISM • The wordpolymorphism means having many forms • In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form. • Polymorphism allows us to perform a single action in different ways, in other words, polymorphism allows you to define one interface and have multiple implementations. • The word “poly” means many and “morph” means forms, so it means many forms
  • 10.
    TYPES OF POLYMORPHISM •In java polymorphism is mainly divided into two types. • Compile-time polymorphism • Run-time polymorphism
  • 11.
    Compile-time polymorphism • Itis also known as static polymorphism. • This type of polymorphism is a achieved by function overloading or operator overloading (java doesn’t support the operator overloading) Method overloading: when there are multiple functions with the same name but different parameters then these functions are said to be overloaded Functions can be overloaded by change in the number of arguments or/and a change in the type of arguments
  • 12.
    Run-time polymorphism • Itis also known as Dynamic method dispatch • It is a process in which a function call to the overridden method is resolved at runtime • This type of polymorphism is achieved by method overriding Method overriding: on the other hand, occurs when a derived class has a definition for one of the member functions of the base class, the base function is said to be overridden.
  • 13.
    INHERITANCE • Inheritance injava is “ a mechanism in which one object acquire all the properties and behaviours of a parent class object “ • It is an important part of oops • The idea behind inheritance in java is that you can create new classes that are built upon existing classes • When you inherit from an existing class, you can reuse methods and fields of parent class • Inheritance represents the IS-A Relationship which is also known as a parent-child relationship
  • 14.
    USES OF INHERITANCE •For method overriding • For code reusability
  • 15.
    TERMS USED ININHERITANCE • CLASS: A class is a group of objects which have common properties it is a template or blueprint from which objects are created • SUB CLASS/CHILD CLASS: Subclass is a class which inherits the other class it is also called derived class, extend class • SUPER CLASS/ PARENT CLASS : Super class is the class from where a subclass inherits the features. it is also called a base class or a parent classs.
  • 16.
    SYNTAX Class Subclass_name extendsSuperclass_name { //Method and Fields } The extend keyword indicates that you are making a new class that derives from an existing class.
  • 17.
    TYPES OF INHERITANCE •On the basis of class there can be three types of inheritance in java. Single, Multilevel and Hierarchical. • In java programming, multiple and hybrid inheritance is supported through interface only. • When one class inherits multiple classes it is known as multiple inheritance.
  • 18.
    • SINGLE INHERITANCE:When a class inherits another class, it is known as a single inheritance • MULTILEVEL INHERITANCE: When there is a chain of inheritance it is known as multilevel inheritance • HIERARCHICAL INHERITANCE: When two or more classes inherits a single class it is known as hierarchical inheritance
  • 19.
    WHY MULTIPLE INHERITANCEIS NOT SUPPORTED IN JAVA? • To reduce the complexity and simplify the language, multiple inheritance is not supported in java • Consider, a scenario where A,B and C are three classes. The C class inherits A and B classes • If A and B classes have the same method and you call it from child class object, there will be ambiguity to call the method of A or B class • Since compile-time errors are better than runtime errors.
  • 20.