SlideShare a Scribd company logo
GLOBAL INSTITUTE OF MANAGEMENT & TECHNOLOGY
Presenting by – SHUVROJIT MAJUMDER (B.tech, CSE)
Year - 3rd Year Sem - 5th sem
Roll No. – 25900120006 Reg. No. – 202590100110010
Sub – OBJECT ORIENTED PROGRAMMING (OOPS)
Sub Code - PCC-CS503
INHERITANCE -
ENCAPSULATION
- POLYMORPHISM
Contents
⮚ INTRODUCTION
⮚ INHERITANCE
⮚ ENCAPSULATION
⮚ POLYMORPHISM
OOP – “Object Oriented Programming” . This is an engineering approach to
build / develop Software System .
“Object” means a real-world entity such as a pen, chair, table, computer,
etc. ”Object-Oriented Programming” is a methodology or paradigm to
design a program using classes and objects.
There are some Key-features of the oop Concept . They are -------
1. Abstraction
1. Inheritance
1. Encapsulation
1. Polymorphism
In this presentation we are discussing about the most important three(3)
Inheritance , Encapsulation , Polymorphism .
INTRODUCTION
Basic OOP Concept
•
Key - Features
•
•
INHERITANCE
⮚ Inheritance in Java is a mechanism in which one object acquires all the
properties and behaviors of a parent object .
⮚ The idea behind inheritance in Java is that we can create new classes, -
which are built upon existing classes. When we inherit from an existing
class, we can re-use methods and fields of the parent class. So that due
to inheritance Code reusability increases .
⮚ Inheritance represents the IS-A relationship which is also known as a –
parent - child relationship .
⮚ Program as example :
class Bike{
int wheel = 2;
}
class SportsBike extends Bike {
int maxSpeed = 180;
public static void main(String args[]){
SportsBike ktm = new SportsBike();
System.out.println(“No.of Wheel in ktm is:"+ktm.wheel);
System.out.println(“Max Speed of
ktm is:"+ktm.maxSpeed+”Km/h”);
}
}
Code
No.of Wheel in ktm is : 2
Max Speed of ktm is : 180 Km/h
Output
⮚ Terminologies used in Inheritance :
⮚ Class : A class is a group of objects which have common
properties. It is a template or blueprint of objects .
• Sub Class/Child Class: Subclass is a class which inherits the
other class. It is also called a derived class, extended class, or
child class.
• Super Class/Parent Class: Superclass is the class from where a
subclass inherits the features. It is also called a base class or a
parent class.
• Reusability : As the name specifies, reusability is a mechanism
which facilitates us to reuse the fields & methods of the existing
class when we create a new class.
• Types Of Inheritance :
ENCAPSULATION
class Name {
private int age; // Private is using to hide the data
public int getAge() { return age; } // getter
public void setAge(int age) {
this.age = age;
} // setter
}
class GFG {
public static void main(String[] args) {
Name n1 = new Name();
n1.setAge(19);
System.out.println(“The age of the person is: ”+
n1.getAge());
}
}
Code
The age of the person is : 19
Output
⮚ Encapsulation in Java is a process of wrapping code and data together
into a single unit, for example, a capsule which is mixed of several
medicines.
⮚ We can create a fully encapsulated class in Java by making all the data
members of the class private. Now we can use setter and getter methods
to set and get the data in it.
⮚ The Java Bean class is the example of a fully encapsulated class.
⮚ Program as example :
Advantages of Encapsulation in Java :
• By providing only a setter or getter method, we can make the
class read-only or write-only. In other words, you can skip the --
getter or setter methods.
• It provides us the control over the data. Suppose we want to set
the value of id which should be greater than 100 only, we can --
write the logic inside the setter method . We also can write the
logic not to store the negative numbers in the setter methods.
• It is a way to achieve data hiding in Java because other class will
not be able to access the data through the private data members.
• The encapsulate class is easy to test. So, it is better for unit testing.
• The standard IDE's are providing the facility to generate the ---
getters and setters. So, it is easy and fast to create an encapsulated
class in Java.
POLYMORPHISM
⮚ 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.
⮚ Real - life Illustration: Polymorphism :
A person at the same time can have different
characteristics. Like a man at the same time is a
father, a Fruit Buyer, an employee. So the same
person possesses different behavior in different
situations. This is called polymorphism .
⮚ Polymorphism is considered one of the
important features of Object-Oriented
Programming. 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 “morphs” means forms, So it means many forms.
⮚ Polymorphism is the ability of one object to be treated and used like ----
another object. As example, we treat duck as an animal and not just as a
duck. Similarly, we treat dog and cat also as animals.
Types of polymorphism :
• In Java polymorphism is mainly divided into two types:
(1) Compile-time Polymorphism /Static Polymorphism –
⮚ Overloading
⮚ Overriding
(2) Runtime Polymorphism / Dynamic 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 polymor ---
phism 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. That base function is said to be
overridden.
THANK
YOU

More Related Content

PPTX
Shuvrojit Majumder . 25900120006 Object Oriented Programming (PCC-CS 503) ...
PPTX
Introduction to OOP concepts
PDF
Cs2305 programming paradigms lecturer notes
PPTX
Object Oriented Programming (OOP) Introduction
PPTX
Object Oriented Programming
PPT
Md02 - Getting Started part-2
PPTX
Lecture 5.pptx
PPTX
OOP-Advanced Programming with c++
Shuvrojit Majumder . 25900120006 Object Oriented Programming (PCC-CS 503) ...
Introduction to OOP concepts
Cs2305 programming paradigms lecturer notes
Object Oriented Programming (OOP) Introduction
Object Oriented Programming
Md02 - Getting Started part-2
Lecture 5.pptx
OOP-Advanced Programming with c++

Similar to Object Oriented Programming.pptx (20)

PDF
JAVA-PPT'S.pdf
PPTX
OOPS 46 slide Python concepts .pptx
PPT
Java_notes.ppt
PPTX
Introduction to OOPs second year cse.pptx
PPTX
OOPS in Java
PPTX
Object Oriented Programming in Python.pptx
DOC
C# by Zaheer Abbas Aghani
DOC
C# by Zaheer Abbas Aghani
PPTX
Introduction to oop
PDF
L1-Introduction to OOPs concepts.pdf
PPTX
arthimetic operator,classes,objects,instant
PPTX
Chapter 04 Object Oriented programming .pptx
PPTX
C++ programming introduction
PPTX
CS3391-Object oriented programmingPPT-TOPIC-3.pptx
PPTX
Selenium Training .pptx
PDF
Oops concepts
PPTX
Pi j3.1 inheritance
PPTX
OOPs Java Module 1.pptx marketing trends social media company profilesmarketi...
PPTX
CPP-Unit 1.pptx
JAVA-PPT'S.pdf
OOPS 46 slide Python concepts .pptx
Java_notes.ppt
Introduction to OOPs second year cse.pptx
OOPS in Java
Object Oriented Programming in Python.pptx
C# by Zaheer Abbas Aghani
C# by Zaheer Abbas Aghani
Introduction to oop
L1-Introduction to OOPs concepts.pdf
arthimetic operator,classes,objects,instant
Chapter 04 Object Oriented programming .pptx
C++ programming introduction
CS3391-Object oriented programmingPPT-TOPIC-3.pptx
Selenium Training .pptx
Oops concepts
Pi j3.1 inheritance
OOPs Java Module 1.pptx marketing trends social media company profilesmarketi...
CPP-Unit 1.pptx
Ad

Recently uploaded (20)

PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
web development for engineering and engineering
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Welding lecture in detail for understanding
PPTX
Geodesy 1.pptx...............................................
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
Digital Logic Computer Design lecture notes
Internet of Things (IOT) - A guide to understanding
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
web development for engineering and engineering
OOP with Java - Java Introduction (Basics)
Model Code of Practice - Construction Work - 21102022 .pdf
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Welding lecture in detail for understanding
Geodesy 1.pptx...............................................
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Foundation to blockchain - A guide to Blockchain Tech
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Automation-in-Manufacturing-Chapter-Introduction.pdf
CH1 Production IntroductoryConcepts.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Digital Logic Computer Design lecture notes
Ad

Object Oriented Programming.pptx

  • 1. GLOBAL INSTITUTE OF MANAGEMENT & TECHNOLOGY Presenting by – SHUVROJIT MAJUMDER (B.tech, CSE) Year - 3rd Year Sem - 5th sem Roll No. – 25900120006 Reg. No. – 202590100110010 Sub – OBJECT ORIENTED PROGRAMMING (OOPS) Sub Code - PCC-CS503 INHERITANCE - ENCAPSULATION - POLYMORPHISM
  • 2. Contents ⮚ INTRODUCTION ⮚ INHERITANCE ⮚ ENCAPSULATION ⮚ POLYMORPHISM
  • 3. OOP – “Object Oriented Programming” . This is an engineering approach to build / develop Software System . “Object” means a real-world entity such as a pen, chair, table, computer, etc. ”Object-Oriented Programming” is a methodology or paradigm to design a program using classes and objects. There are some Key-features of the oop Concept . They are ------- 1. Abstraction 1. Inheritance 1. Encapsulation 1. Polymorphism In this presentation we are discussing about the most important three(3) Inheritance , Encapsulation , Polymorphism . INTRODUCTION Basic OOP Concept • Key - Features • •
  • 4. INHERITANCE ⮚ Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object . ⮚ The idea behind inheritance in Java is that we can create new classes, - which are built upon existing classes. When we inherit from an existing class, we can re-use methods and fields of the parent class. So that due to inheritance Code reusability increases . ⮚ Inheritance represents the IS-A relationship which is also known as a – parent - child relationship . ⮚ Program as example : class Bike{ int wheel = 2; } class SportsBike extends Bike { int maxSpeed = 180; public static void main(String args[]){ SportsBike ktm = new SportsBike(); System.out.println(“No.of Wheel in ktm is:"+ktm.wheel); System.out.println(“Max Speed of ktm is:"+ktm.maxSpeed+”Km/h”); } } Code No.of Wheel in ktm is : 2 Max Speed of ktm is : 180 Km/h Output
  • 5. ⮚ Terminologies used in Inheritance : ⮚ Class : A class is a group of objects which have common properties. It is a template or blueprint of objects . • Sub Class/Child Class: Subclass is a class which inherits the other class. It is also called a derived class, extended class, or child class. • Super Class/Parent Class: Superclass is the class from where a subclass inherits the features. It is also called a base class or a parent class. • Reusability : As the name specifies, reusability is a mechanism which facilitates us to reuse the fields & methods of the existing class when we create a new class. • Types Of Inheritance :
  • 6. ENCAPSULATION class Name { private int age; // Private is using to hide the data public int getAge() { return age; } // getter public void setAge(int age) { this.age = age; } // setter } class GFG { public static void main(String[] args) { Name n1 = new Name(); n1.setAge(19); System.out.println(“The age of the person is: ”+ n1.getAge()); } } Code The age of the person is : 19 Output ⮚ Encapsulation in Java is a process of wrapping code and data together into a single unit, for example, a capsule which is mixed of several medicines. ⮚ We can create a fully encapsulated class in Java by making all the data members of the class private. Now we can use setter and getter methods to set and get the data in it. ⮚ The Java Bean class is the example of a fully encapsulated class. ⮚ Program as example :
  • 7. Advantages of Encapsulation in Java : • By providing only a setter or getter method, we can make the class read-only or write-only. In other words, you can skip the -- getter or setter methods. • It provides us the control over the data. Suppose we want to set the value of id which should be greater than 100 only, we can -- write the logic inside the setter method . We also can write the logic not to store the negative numbers in the setter methods. • It is a way to achieve data hiding in Java because other class will not be able to access the data through the private data members. • The encapsulate class is easy to test. So, it is better for unit testing. • The standard IDE's are providing the facility to generate the --- getters and setters. So, it is easy and fast to create an encapsulated class in Java.
  • 8. POLYMORPHISM ⮚ 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. ⮚ Real - life Illustration: Polymorphism : A person at the same time can have different characteristics. Like a man at the same time is a father, a Fruit Buyer, an employee. So the same person possesses different behavior in different situations. This is called polymorphism . ⮚ Polymorphism is considered one of the important features of Object-Oriented Programming. 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 “morphs” means forms, So it means many forms. ⮚ Polymorphism is the ability of one object to be treated and used like ---- another object. As example, we treat duck as an animal and not just as a duck. Similarly, we treat dog and cat also as animals.
  • 9. Types of polymorphism : • In Java polymorphism is mainly divided into two types: (1) Compile-time Polymorphism /Static Polymorphism – ⮚ Overloading ⮚ Overriding (2) Runtime Polymorphism / Dynamic 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 polymor --- phism 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. That base function is said to be overridden.