Presentation 2
Presentation 2
Programming
•
Submitted To:-Mrs. Ipsita Panda
INDEX
• Introduction of OOPs
• Classes and objects
• Pillars of OOPS
• Advantages of OOPs
• References
Introduction of Object Oriented Programming?
• Object-oriented programming (OOP) is a programming paradigm
that uses the concepts of classes and objects.
Class is a logical construct which explains the structure and behavior
of an object.
Example: A Car class can have attributes like color and brand, and
methods like drive( ) and stop( ).
• An object has a physical existence; hence, it consumes memory.
• Once a class is designed, we can create any number of objects.
Four pillars of oops
• ABSTRACTION
• INHERITANCE
• ENCAPSULATION
• POLIMORPHISM
•
04/15/2025
Abstraction
Abstraction is a mechanism in Java that hides the background details and shows only the essential information.
• Example: • }
• abstract class A { • }
• abstract void Add(); • public class AbstractDemo {
• } • public static void main(String[]
• class B extends A { args) {
• public void Add() { • B aa = new B();
• int a = 10; • aa.Add();
• int b = 20; • }
• int c = a + b; • }
• System.out.println(c); • //output=30 5
Inheritance
• When one class accesses the properties of another class is called inheritance
Types of Inheritance
• 1. Single inheritance
• 2. Multilevel inheritance
• 3. Hierarchical inheritance
• 4. Hybrid inheritance
• Note Java does not support multiple inheritances at the class
level but can be achieved through an interface.
04/15/2025
Single Inheritance
In single inheritance, a sub-class is derived from only one super class. It inherits the properties and behavior of a
single-parent class. Sometimes it is also known as simple inheritance.
• class A {
• Int a=10; • int c = a + b;
• Int b=20; •
System.out.println(c);
• }
• }
• class B extends A {
• }
• public void Add() {
7
04/15/2025
Multilevel Inheritance
Multilevel inheritance is when a class inherits from another class, and then another class inherits from it.
This creates a chain where properties and methods are passed down through multiple levels.
• class D extends B {
• class A {
• public void addition() {
• int a = 50;
• int e = a + b + d;
• int b = 50;
• System.out.println(e);
• }
• }
• class B extends A { • }
• int d = 20; • public class Demo {
• int c = a + b;
• D aa = new D();
• aa.add();
• System.out.println(c);
• aa.addition();
• }
• }
• }
• } 8
Hierarchical Inheritance
04/15/2025
• if a number of classes are derived from a single base class, it is called
hierarchical inheritance.
• class A { • int d = a - b;
• int a = 50;
• System.out.println(d);
• }
• int b = 50;
• }
• }
• public class Demo {
• class B extends A { • public static void main(String[] args) {
• public void add() { • B bb = new B();
• int c = a + b; • bb.add();
12
Method Overriding
04/15/2025
Overriding in Java means defining a method in a child class that
already exists in the parent class with the same name, return
type, and parameters. This allows the child class to provide a
new version of the method.
• class Shape { • System.out.println("Square shape");
• void draw() { • }
• System.out.println("shape
• }
type"); • class Add {
• } • public static void main(String[]
args) {
• }
• Square aa = new Square();
• class Square extends Shape {
• aa.draw();
• @Override • }
• void draw() { • }
13
Encapsulation
References
Google :- www.geeksforgeeks.org/oops-concept-in-java/
Wikipedia:-https://en.wikipedia.org/wiki/Object-
oriented_programming
• Thank you