Slide 2024
Slide 2024
1
3. Brief History and Evolution
Early Beginnings: "The concept of OOP dates back to the 1960s with the development of
languages like Simula, which introduced classes and objects."
Evolution: "In the 1980s and 1990s, OOP gained widespread adoption with languages like
Smalltalk, C++, and Java, which brought OOP principles to mainstream software development."
Modern Usage: "Today, OOP is a foundational concept in many modern programming
languages, including Python, C#, and Ruby."
The development of Object-Oriented Programming:
o 1967: Simula 67 – Introduced core OOP concepts.
o 1980: Smalltalk – Pioneered many OOP features.
o 1985: C++ – Extended C with OOP.
o 1995: Java – Popularized OOP with cross-platform capabilities.
o 2000: C# – Modern OOP features in .NET framework.
o 2000s: Python, Ruby, TypeScript – Continued evolution and integration with modern
programming paradigms.
2
2. Encapsulation
Encapsulation is the bundling of data (attributes) and methods (functions) that operate on the
data into a single unit, typically a class. It restricts direct access to some of the object's
components, which can help prevent unintended interference and misuse.
Key Points:
o Private vs. Public: Access modifiers that control visibility (e.g., private, protected,
public).
o Getter and Setter Methods: Used to access and update private attributes.
Example Java Code:
public class Person {
private String name; // Private attribute
private int age; // Private attribute
3
setName(String name)
getAge()
setAge(int age)
3. Abstraction
Abstraction is the concept of hiding the complex implementation details and showing only the
necessary features of an object. It allows us to work with complex systems by interacting with
simpler interfaces.
Key Points:
o Abstract Classes and Methods: Abstract classes cannot be instantiated and are designed
to be inherited. Abstract methods must be implemented by subclasses.
Example Java Code:
abstract class Animal {
// Abstract method (does not have a body)
public abstract void makeSound();
}
4
Diagram showing an abstract class with abstract methods and derived classes implementing
class Class Model
these methods.
«abstract»
Animal
«abstract»
+ makeSound(): void
Dog Cat
4. Inheritance
Inheritance is a mechanism where a new class inherits attributes and methods from an existing
class. This allows for code reusability and the creation of a hierarchical relationship between
classes.
Key Points:
o Base Class and Derived Class: The base class is the parent class, and the derived class
inherits from it.
o Method Overriding: Derived classes can override methods of the base class.
Example Java Code:
class Animal {
public void eat() {
System.out.println("Eating");
}
}
5
Diagram of a class hierarchy showing base and derived classes.
Dog Animal
5. Polymorphism
Polymorphism allows objects of different classes to be treated as objects of a common base
class. It enables one interface to be used for a general class of actions, with specific actions
defined in derived classes.
Key Points:
o Method Overloading and Overriding: Overloading refers to defining multiple methods
with the same name but different parameters. Overriding refers to redefining a method in
a derived class.
Example Java Code:
abstract class Animal {
public abstract void makeSound () ;
}
6
makeAnimalSound (cat); // Output: Meow
}
}
class Class Model
Diagram showing method overriding and a function demonstrating polymorphism.
«abstract»
Animal
«abstract»
+ makeSound(): void
Dog Cat
Slide 4: Encapsulation
Definition and explanation
How it works (e.g., private vs. public access)
Example Java or C# code
7
3. Example Code in C#
Slide 5: Abstraction
Definition and explanation
Abstract classes and methods
Example code in Python
Slide 6: Inheritance
Definition and explanation
Base and derived classes
Example code in Python
Slide 7: Polymorphism
Definition and explanation
Method overriding and overloading
Example code in Python
10