0% found this document useful (0 votes)
3 views

Object-Oriented Programming Slides Copy

The document provides an overview of Object-Oriented Programming (OOP), detailing its core principles such as encapsulation, inheritance, polymorphism, and abstraction. It explains key characteristics of OOP, including class-based structure, message passing, and self-contained modules, along with important features like access modifiers and constructors. The historical context of OOP's evolution and its significance in programming is also highlighted.
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)
3 views

Object-Oriented Programming Slides Copy

The document provides an overview of Object-Oriented Programming (OOP), detailing its core principles such as encapsulation, inheritance, polymorphism, and abstraction. It explains key characteristics of OOP, including class-based structure, message passing, and self-contained modules, along with important features like access modifiers and constructors. The historical context of OOP's evolution and its significance in programming is also highlighted.
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
You are on page 1/ 16

Object-Oriented

Programming
Principles, Characteristics, and Features
Overview
Introduction to Object-Oriented
Programming
Core OOP Principles
Key Characteristics of OOP
OOP Features
Summary
Introduction What is OOP?
• A programming paradigm based on the
to Object- concept of "objects"
• Objects contain data (attributes) and

Oriented code (methods)


• Programs are designed by creating

Programmin
objects that interact with one another
• Evolved as an alternative to procedural
programming
g
Historical Context
• First appeared in Simula 67 in the 1960s
• Popularized by Smalltalk in the 1970s
• Mainstream adoption with C++ (1980s)
and Java (1990s)
The core OOPs Principles
Class
Objects
Inheritance
Abstraction
Polymorphism
Encapsulation
Class class BankAccount {
private double balance;
• A class is a blueprint or
template for creating public void deposit(double amount) {
objects. if (amount > 0) {

• It defines properties balance += amount;


}
(fields) and methods
}
(functions).
}
• Classes encapsulate data
and behavior.
• BankAccount is a class with one property
• They support modularity (balance) and one method (deposit)
and code reuse.
Object BankAccount myAccount = new
BankAccount();
• An object is an instance of myAccount.deposit(500.0);
a class.
• It represents a real-world • myAccount is the object
entity with state (data) and • It has access to balance and deposit()
defined in the BankAccount class
behavior (methods).
• Created using the new
keyword.
• Multiple objects can be
created from a single
class.
class Animal {

Inheritance void eat() {


/* implementation */
}
• allows a class to acquire
properties and methods from
another class. }
• Promotes code reuse and class Dog extends Animal {
establishes a parent-child void bark() {
relationship. /* implementation */
• The child class is called a } // Dog inherits eat()
subclass, and the parent class method
is a superclass. }
• Use the extends keyword in
Java
Abstraction
abstract class Shape {
• hides complex
abstract void draw();
implementation and shows
}
only essential features.
class Circle extends Shape {
• Focuses on what an object
void draw() {
does, not how.
System.out.println("Drawing
• Achieved using abstract a circle");
classes and interfaces in Java. }
}

• Shape defines a general concept


• Circle provides the specific
implementation
Polymorphism class Animal {
public void sound() {
System.out.println("Animal
• Ability of objects to take on makes a sound");
many forms }
}
• Same interface, different
class Dog extends Animal {
implementations
public void sound() {
• Achieved via method
System.out.println("Dog
overriding (runtime) and barks");
method overloading }
(compile-time). }
• Enhances flexibility and • Sound behaves differently in dog
reusability. and animal
• Same method name, different
implementations
class BankAccount {
Encapsulation private double balance; //
hidden data
public void deposit(double
• Encapsulation is the process of amount) {
hiding internal data and only exposing if (amount > 0) {
necessary parts through methods. balance += amount;
• Achieved by making variables }
private and providing public }
getter/setter methods. public double getBalance() {
return balance;
• Helps protect object integrity and }
improves code maintainability.
•Balance cannot be accessed directly
•Access is controlled through
getBalance() and deposit() methods
Key Characteristics of OOP

Objects as Primary Elements Class-Based Structure


• Real-world entities • Classes define structure and
behavior of objects
represented as objects
• Objects are instances of classes
• Every object belongs to a
• Classes form relationships with
class (blueprint) other classes
• Objects have:
• State (attributes/data)
• Behavior (methods/functions)
• Identity (unique memory
existence)
Key Characteristics of OOP
Cont…
Message Passing Self-Contained Modules
• Objects communicate by • Each object is a self-
sending messages contained unit
• Messages trigger method • Modular design makes
execution systems easier to:
• • Develop
Enables loose coupling
• Maintain
between components
• Extend
Important OOP Features

Access Modifiers
• Control the visibility of class members
• Common modifiers:
• Public: Accessible from anywhere
• Private: Accessible only within the class
• Protected: Accessible within the class and its subclasses
• Default (package-private): Accessible within the same package
Important OOP Features Cont…

Interfaces and Abstract Classes


• Interfaces: Define a contract without implementation
• Abstract Classes: Partially implemented classes
• Both support polymorphism and abstraction

Constructors
• Special methods for initializing objects
• Can be overloaded for different initialization scenarios
Summary: The Four Pillars of
OOP

01 02 03 04
Encapsulation Inheritance: Polymorphis Abstraction:
: Binding data Creating new m: Objects Simplifying
with the classes from taking multiple complex
methods that existing ones forms systems by
manipulate it depending on focusing on
context essentials
Thank You!
Any Questions?

You might also like