P1WU UNIT – I: INTRODUCTION TO OOP AND JAVA TOPIC -3: FEATURES OF OBJECT ORIENTED PROGRAMMING AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
UNIT I INTRODUCTION TO OOP AND JAVA 1. Overview of OOP 2. Object oriented programming paradigms 3. Features of Object Oriented Programming 4. Java Buzzwords 5. Overview of Java – Data Types, Variables and Arrays 6.Operators 7.Control Statements 8.Defining classes in Java 9.Constructors 10.Methods 11. Access specifiers 12.Static members 13. JavaDoc comments AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
FEATURES OF OBJECT ORIENTED PROGRAMMING AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
FEATURES OF OBJECT ORIENTED PROGRAMMING • The Object–Oriented Programming principles are defended with concepts of Object–Oriented Systems (OOPS) 1. Object 2. Class 3. Encapsulation 4. Abstraction 5. Polymorphism 6. Inheritance AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
a) Object • An object is a real-world element in an object–oriented environment that may have a physical or a conceptual existence. Each object has − • Identity that distinguishes it from other objects in the system. • State that determines characteristic properties of an object as well as values of properties that the object holds. • Behavior that represents externally visible activities performed by an object in terms of changes in its state. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
a) Object • Objects can be modeled according to the needs of the application. • An object may have a physical existence, like a customer, a car, etc.; or an intangible conceptual existence, like a project, a process, etc. • Object means a real word entity such as pen, chair, table etc. • Any entity that has state and behavior is known as an object. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
a) Object • Object can be defined as an instance of a class. • An object contains an address and takes up some space in memory. • Objects can communicate without knowing details of : • each other's data or code, • the only necessary thing is that the type of message accepted and • type of response returned by the objects. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
a) Object • An object has three characteristics: • state: represents data (value) of an object. • behavior: represents the behavior (functionality) of an object such as deposit, withdraw etc. • identity: Object identity is typically implemented via a unique ID. • The value of the ID is not visible to the external user. But, it is used internally by the JVM to identify each object uniquely. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
b) Class • A class represents a collection of objects having same characteristic properties that exhibit common behavior. • It gives the blueprint or the description of the objects that can be created from it. • Creation of an object as a member of a class is called instantiation. • Collection of objects is called class. • It is a logical entity. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
b) Class • A class can also be defined as a blueprint from which you can create an individual object. • A class consists of Data members and methods. • The primary purpose of a class is to hold data/information. • The member functions determine the behavior of the class, • i.e. provide a definition for supporting various operations on data held in the form of an object.Class doesn’t store any space. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
b) Class • Thus, an object is an instance of a class. • The constituents of a class are − 1. A set of attributes for the objects that are to be instantiated from the class. • Generally, different objects of a class have some difference in the values of the attributes. • Attributes are often referred as class data. 2. A set of operations that portray the behavior of the objects of the class. Operations are also referred as functions or methods AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
b) Class • Example • Let us consider a simple class, Circle, that represents the geometrical figure circle in a two–dimensional space. • The attributes of this class can be identified as follows − • x–coord, to denote x–coordinate of the center • y–coord, to denote y–coordinate of the center • a, to denote the radius of the circle AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
b) Class • Some of its operations can be defined as follows − 1. findArea(), a method to calculate area 2. findCircumference(), a method to calculate circumference 3. scale(), a method to increase or decrease the radius AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
c) Encapsulation • Encapsulation is • the process of binding both attributes and methods together within a class. • Encapsulation in java is a process of wrapping code and data together into a single unit, • for example capsule i.e. mixed of several medicines. • Through encapsulation, the internal details of a class can be hidden from outside. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
c) Encapsulation • It permits • the elements of the class to be accessed from outside only through the interface provided by the class. • A java class is the example of encapsulation. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
d) Abstraction • Abstraction is • a process of hiding the implementation details and showing only functionality to the user. • Example: • phone call, we don't know the internal processing. • In java, we use abstract class and interface to achieve abstraction. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
e) Polymorphism • Polymorphism is originally a Greek word that means the ability to take multiple forms. • Ploy  Many • Morphism  Form • In object-oriented paradigm, polymorphism implies: • using operations in different ways, depending upon the instances they are operating upon. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
e) Polymorphism • Polymorphism allows • objects with different internal structures to have a common external interface. • Use: • Polymorphism is particularly effective while implementing inheritance. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
e) Polymorphism : Example • Let us consider two classes, • Circle class • Square class • Look for Poly- method called findArea(). • Here, Circle and Square, each with a method findArea(). AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
e) Polymorphism : Example • Though the name and purpose of the methods in the classes are same, the internal implementation, • i.e., the procedure of calculating an area is different for each class. • When an object of class Circle invokes its findArea() method, • the operation finds the area of the circle without any conflict with the findArea() method of the Square class. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
e) Polymorphism : Example • When one task is performed by different ways i.e. known as polymorphism. • For example: to convince the customer differently, to draw something e.g. shape or rectangle etc. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
Types of Polymorphism • Polymorphism is classified into two ways: 1) Method Overloading(Compile time Polymorphism) 2) Method Overriding(Run time Polymorphism) AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
1) Method Overloading(Compile time Polymorphism) • Method Overloading is a feature that allows • a class to have two or more methods having the same name but the arguments passed to the methods are different. • Compile time polymorphism refers to • a process in which a call to an overloaded method is resolved at compile time rather than at run time. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
2) Method Overriding(Run time Polymorphism) • If subclass (child class) has the same method as declared in the parent class, it is known as method overriding in java. • If subclass provides the specific implementation of the method that has been provided by one of its parent class, it is known as method overriding. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
f) Inheritance • It is a mechanism that permits • new classes to be created out of existing classes by extending and refining its capabilities. Scenario: Having / implementing more than one class • The existing classes are called the base classes/parent classes/super-classes, and • the new classes are called the derived classes/child classes/subclasses. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
f) Inheritance • Facility from inherit property: • The subclass can inherit or derive the attributes and methods of the super-class (es) provided that the super-class allows so. • Besides, the subclass may add its own attributes and methods and may modify any of the super-class methods. Inheritance defines a “is – a” relationship. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
f) Inheritance • What is an Inheritance? • Inheritance can be defined as the procedure or mechanism of acquiring all the properties and behavior of one class to another, i.e., acquiring the properties and behavior of child class from the parent class. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
f) Inheritance • When one object acquires all the properties and behaviours of another object, it is known as inheritance. • It provides code reusability and establishes relationships between different classes. • A class which inherits the properties is known as Child Class(sub- class or derived class) whereas a class whose properties are inherited is known as Parent class(super-class or base class). AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
f) Inheritance • Types of inheritance • Types of inheritance in java: 1. single, 2. multilevel and 3. hierarchical inheritance. • Multiple and hybrid inheritance is supported through interface only. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
f) Inheritance • Example • From a class Mammal, a number of classes can be derived such as Human, Cat, Dog, Cow, etc. Humans, cats, dogs, and cows all have the distinct characteristics of mammals. • In addition, each has its own particular characteristics. • It can be said that a cow “is – a” mammal. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
Features of object oriented programming paradigm 1. Programs are divided into simple elements referred to as object 2. Focus is on properties and functions rather than procedure. 3. Data is hidden from external functions. 4. Functions operate on the properties of an object. 5. Objects may communicate with each other through a function called messaging. 6. Follow the bottom-up approach in oop design AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
THANK YOU AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA

CS3391 OOP UT-I T3 FEATURES OF OBJECT ORIENTED PROGRAMMING

  • 1.
    P1WU UNIT – I:INTRODUCTION TO OOP AND JAVA TOPIC -3: FEATURES OF OBJECT ORIENTED PROGRAMMING AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 2.
    UNIT I INTRODUCTIONTO OOP AND JAVA 1. Overview of OOP 2. Object oriented programming paradigms 3. Features of Object Oriented Programming 4. Java Buzzwords 5. Overview of Java – Data Types, Variables and Arrays 6.Operators 7.Control Statements 8.Defining classes in Java 9.Constructors 10.Methods 11. Access specifiers 12.Static members 13. JavaDoc comments AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 3.
    FEATURES OF OBJECTORIENTED PROGRAMMING AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 4.
    FEATURES OF OBJECTORIENTED PROGRAMMING • The Object–Oriented Programming principles are defended with concepts of Object–Oriented Systems (OOPS) 1. Object 2. Class 3. Encapsulation 4. Abstraction 5. Polymorphism 6. Inheritance AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 5.
    a) Object • Anobject is a real-world element in an object–oriented environment that may have a physical or a conceptual existence. Each object has − • Identity that distinguishes it from other objects in the system. • State that determines characteristic properties of an object as well as values of properties that the object holds. • Behavior that represents externally visible activities performed by an object in terms of changes in its state. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 6.
    a) Object • Objectscan be modeled according to the needs of the application. • An object may have a physical existence, like a customer, a car, etc.; or an intangible conceptual existence, like a project, a process, etc. • Object means a real word entity such as pen, chair, table etc. • Any entity that has state and behavior is known as an object. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 7.
    a) Object • Objectcan be defined as an instance of a class. • An object contains an address and takes up some space in memory. • Objects can communicate without knowing details of : • each other's data or code, • the only necessary thing is that the type of message accepted and • type of response returned by the objects. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 8.
    a) Object • Anobject has three characteristics: • state: represents data (value) of an object. • behavior: represents the behavior (functionality) of an object such as deposit, withdraw etc. • identity: Object identity is typically implemented via a unique ID. • The value of the ID is not visible to the external user. But, it is used internally by the JVM to identify each object uniquely. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 9.
    b) Class • Aclass represents a collection of objects having same characteristic properties that exhibit common behavior. • It gives the blueprint or the description of the objects that can be created from it. • Creation of an object as a member of a class is called instantiation. • Collection of objects is called class. • It is a logical entity. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 10.
    b) Class • Aclass can also be defined as a blueprint from which you can create an individual object. • A class consists of Data members and methods. • The primary purpose of a class is to hold data/information. • The member functions determine the behavior of the class, • i.e. provide a definition for supporting various operations on data held in the form of an object.Class doesn’t store any space. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 11.
    b) Class • Thus,an object is an instance of a class. • The constituents of a class are − 1. A set of attributes for the objects that are to be instantiated from the class. • Generally, different objects of a class have some difference in the values of the attributes. • Attributes are often referred as class data. 2. A set of operations that portray the behavior of the objects of the class. Operations are also referred as functions or methods AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 12.
    b) Class • Example •Let us consider a simple class, Circle, that represents the geometrical figure circle in a two–dimensional space. • The attributes of this class can be identified as follows − • x–coord, to denote x–coordinate of the center • y–coord, to denote y–coordinate of the center • a, to denote the radius of the circle AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 13.
    b) Class • Someof its operations can be defined as follows − 1. findArea(), a method to calculate area 2. findCircumference(), a method to calculate circumference 3. scale(), a method to increase or decrease the radius AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 14.
    c) Encapsulation • Encapsulationis • the process of binding both attributes and methods together within a class. • Encapsulation in java is a process of wrapping code and data together into a single unit, • for example capsule i.e. mixed of several medicines. • Through encapsulation, the internal details of a class can be hidden from outside. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 15.
    c) Encapsulation • Itpermits • the elements of the class to be accessed from outside only through the interface provided by the class. • A java class is the example of encapsulation. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 16.
    d) Abstraction • Abstractionis • a process of hiding the implementation details and showing only functionality to the user. • Example: • phone call, we don't know the internal processing. • In java, we use abstract class and interface to achieve abstraction. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 17.
    e) Polymorphism • Polymorphismis originally a Greek word that means the ability to take multiple forms. • Ploy  Many • Morphism  Form • In object-oriented paradigm, polymorphism implies: • using operations in different ways, depending upon the instances they are operating upon. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 18.
    e) Polymorphism • Polymorphismallows • objects with different internal structures to have a common external interface. • Use: • Polymorphism is particularly effective while implementing inheritance. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 19.
    e) Polymorphism :Example • Let us consider two classes, • Circle class • Square class • Look for Poly- method called findArea(). • Here, Circle and Square, each with a method findArea(). AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 20.
    e) Polymorphism :Example • Though the name and purpose of the methods in the classes are same, the internal implementation, • i.e., the procedure of calculating an area is different for each class. • When an object of class Circle invokes its findArea() method, • the operation finds the area of the circle without any conflict with the findArea() method of the Square class. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 21.
    e) Polymorphism :Example • When one task is performed by different ways i.e. known as polymorphism. • For example: to convince the customer differently, to draw something e.g. shape or rectangle etc. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 22.
    Types of Polymorphism •Polymorphism is classified into two ways: 1) Method Overloading(Compile time Polymorphism) 2) Method Overriding(Run time Polymorphism) AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 23.
    1) Method Overloading(Compiletime Polymorphism) • Method Overloading is a feature that allows • a class to have two or more methods having the same name but the arguments passed to the methods are different. • Compile time polymorphism refers to • a process in which a call to an overloaded method is resolved at compile time rather than at run time. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 24.
    2) Method Overriding(Runtime Polymorphism) • If subclass (child class) has the same method as declared in the parent class, it is known as method overriding in java. • If subclass provides the specific implementation of the method that has been provided by one of its parent class, it is known as method overriding. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 25.
    f) Inheritance • Itis a mechanism that permits • new classes to be created out of existing classes by extending and refining its capabilities. Scenario: Having / implementing more than one class • The existing classes are called the base classes/parent classes/super-classes, and • the new classes are called the derived classes/child classes/subclasses. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 26.
    f) Inheritance • Facilityfrom inherit property: • The subclass can inherit or derive the attributes and methods of the super-class (es) provided that the super-class allows so. • Besides, the subclass may add its own attributes and methods and may modify any of the super-class methods. Inheritance defines a “is – a” relationship. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 27.
    f) Inheritance • Whatis an Inheritance? • Inheritance can be defined as the procedure or mechanism of acquiring all the properties and behavior of one class to another, i.e., acquiring the properties and behavior of child class from the parent class. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 28.
    f) Inheritance • Whenone object acquires all the properties and behaviours of another object, it is known as inheritance. • It provides code reusability and establishes relationships between different classes. • A class which inherits the properties is known as Child Class(sub- class or derived class) whereas a class whose properties are inherited is known as Parent class(super-class or base class). AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 29.
    f) Inheritance • Typesof inheritance • Types of inheritance in java: 1. single, 2. multilevel and 3. hierarchical inheritance. • Multiple and hybrid inheritance is supported through interface only. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 30.
    f) Inheritance • Example •From a class Mammal, a number of classes can be derived such as Human, Cat, Dog, Cow, etc. Humans, cats, dogs, and cows all have the distinct characteristics of mammals. • In addition, each has its own particular characteristics. • It can be said that a cow “is – a” mammal. AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 31.
    Features of objectoriented programming paradigm 1. Programs are divided into simple elements referred to as object 2. Focus is on properties and functions rather than procedure. 3. Data is hidden from external functions. 4. Functions operate on the properties of an object. 5. Objects may communicate with each other through a function called messaging. 6. Follow the bottom-up approach in oop design AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 32.
    THANK YOU AALIM MUHAMMEDSALEGH COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA
  • 33.
    AALIM MUHAMMED SALEGHCOLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY SEMESTER – III UNIT I INTRODUCTION TO OOP AND JAVA