0% found this document useful (0 votes)
37 views17 pages

OOP Concepts in Java Explained

The document provides an overview of Object-Oriented Programming (OOP) in Java, detailing its core concepts, the four pillars of OOP (encapsulation, inheritance, polymorphism, and abstraction), and real-world analogies. It explains why Java is not considered 100% object-oriented due to the presence of primitive types and static methods. The conclusion emphasizes the importance of understanding OOP principles for effective software development.

Uploaded by

py8k27s5g5
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views17 pages

OOP Concepts in Java Explained

The document provides an overview of Object-Oriented Programming (OOP) in Java, detailing its core concepts, the four pillars of OOP (encapsulation, inheritance, polymorphism, and abstraction), and real-world analogies. It explains why Java is not considered 100% object-oriented due to the presence of primitive types and static methods. The conclusion emphasizes the importance of understanding OOP principles for effective software development.

Uploaded by

py8k27s5g5
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Object-Oriented Programming

(OOP) in Java
Concepts, Examples & Why Java Isn’t
100% Object-Oriented
Presented by: Anubhav Singh Parihar
Agenda
• • What is OOP?
• • 4 Pillars of OOP
• • Real-world analogies
• • Java OOP examples
• • Why Java is not 100% Object-Oriented
• • Conclusion
What is OOP?
• • A programming paradigm based on the
concept of 'objects'
• • Objects represent real-world entities
• • Combines data and methods
• • Promotes modular, reusable, and
maintainable code
Real-World Analogy: Car
• • Properties: color, brand, speed
• • Behaviors: start(), stop(), accelerate()
• • A car object encapsulates both data and
behavior
Pillar 1: Encapsulation
• • Wrapping data and methods into a single
unit
• • Use of private variables and public
getters/setters
• Example:
• class Person {
• private String name;
• public void setName(String name)
{ [Link] = name; }
Pillar 2: Inheritance
• • Acquiring properties and behaviors from a
parent class
• • Promotes code reuse
• Example:
• class Animal {
• void eat() { [Link]("This animal
eats food."); }
• }
• class Dog extends Animal {
Pillar 3: Polymorphism
• • One interface, multiple implementations
• • Method overloading (compile-time), method
overriding (runtime)
• Example:
• class Animal {
• void sound() { [Link]("Animal
sound"); }
• }
• class Cat extends Animal {
Pillar 4: Abstraction
• • Hiding internal details and showing only
essential features
• • Use of abstract classes or interfaces
• Example:
• abstract class Shape {
• abstract void draw();
• }
• class Circle extends Shape {
• void draw() { [Link]("Drawing
All Pillars Together: Vehicle System
• • Encapsulation: speed, gear (private)
• • Inheritance: Car extends Vehicle
• • Polymorphism: startEngine() behaves
differently in Bike, Car
• • Abstraction: Interface Drivable
Is Java 100% Object-Oriented?
• • No, Java is not fully object-oriented.
• Reasons:
• 1. Primitive types (int, float, char) are not
objects
• 2. Static methods can be called without
objects
• 3. Main() method is static, not tied to object
• 4. Wrapper classes mimic object behavior for
primitives
Primitive vs Object
• • int a = 5; // primitive type
• • Integer b = 5; // object (Wrapper class)
• • Java introduced Autoboxing/Unboxing
• • But primitives still exist outside object model
Static Method Example
• class Utility {
• static int add(int a, int b) { return a + b; }
• }
• [Link](5, 10); // called without an object
• • Static methods go against pure OOP
principles
Summary - Java and OOP
• Encapsulation: ✅
• Inheritance: ✅
• Polymorphism: ✅
• Abstraction: ✅
• 100% Object-Oriented: ❌
Advantages of OOP
• • Reusability
• • Modularity
• • Scalability
• • Maintainability
Real-World Example: Banking
System
• • Customer: name, balance → class
• • Account: deposit(), withdraw()
• • Inheritance: SavingsAccount,
CurrentAccount
• • Polymorphism: interestCalculation() differs
Conclusion
• • OOP is foundational in modern
programming
• • Java supports OOP strongly, but not
completely
• • Understanding core pillars helps build better
software
Thank You!
• • Q&A / Comments Section
• 🔗 Subscribe | 💬 Comment | 👍 Like

You might also like