Professional Documents
Culture Documents
2 OOP Concepts and Features
2 OOP Concepts and Features
Dr. Prabu M
1
Object Objects interact with each other to have something happen.
2
A program where a person get into a
car and drive from A to B.
A B
• Includes 2 things:
• Object 1: Person and
• Object 2: Car
• Person knows how to drive a car
• And a car knows where its going to
be driven.
3
Class You should have class before you create an Object.
Blueprint of an object
To use class person in a program, you should create an object.
4
Method
Procedure associated with a class
To make OBJECT do something
Class Person
Person 1: Person 2:
---------------------- ----------------------
Name: Jim Name: Mary
-------------------------- --------------------------
Methods: Methods:
Walking Walking
Driving Driving
5
Objects and Classes
6
Data
Dog Members
Common Characteristics shared by dogs: Identified
❑Breed
❑Size
❑Age
❑Color
7
Dog
Identity Common Behaviours
❑Eat
❑Sit
❑Sleep
❑Run
8
Classes, Objects and Methods
Object 1
Object 2
Object 3
9
OOP Concepts
❑Abstraction
❑Encapsulation
❑Inheritance
❑Polymorphism.
10
Abstraction
Top 10 information of your customer to create a banking application.
11
Abstraction
We are selecting data from a larger pool.
Same data once
❑Full name abstracted can be used in
wide applications
❑Address
❑Contact Number
❑Tax Information ❑Banking
❑Employee
❑Hospital
❑Government 12
Abstraction
• Only the essential details are displayed to the user.
• The non-essentials units are not displayed to the user.
13
Encapsulation
• A mechanism to wrap up variables(data) and methods(code) together
as a single unit.
• It is the process of hiding information details and protecting data and
behavior of the object.
14
Why??
Entity Property
16
What How
18
Super Class
Single Inheritance
• One class extends another
class Sub Class
19
Multiple Inheritance
• One class extending more than one class. Java does not support
multiple inheritance.
• Class C extends Class A and Class B both.
20
Multilevel Inheritance
• One class can inherit from a derived class.
• Class C is subclass of B and B is a subclass of Class A.
21
Hierarchical Inheritance
• One class is inherited by many sub classes.
• Class B, C, and D inherit the same class A.
22
Hybrid Inheritance
• Hybrid inheritance is a combination
of other inheritances.
23
Polymorphism
• The ability of an object to take on many forms
24