OPP programming (OOP) is a programming pattern based on the concept of "objects" that are examples of a class. These objects can contain data (properties) and code (methods) that work with data.
Important Concepts OOP:Class: Design to create objects. Defines the features and methods that an object has.
Object: An example of class. This represents a real -world creature with actions and countries.
Encapsulation: You must hide the internal status of an object and do all the interactions using object methods.
Inheritance: Allows one class to inherit the properties and behavior (methods) from another class.
Poly Morphism: Even if they are in common with the same name, this method can behave differently based on the objects they call.
Abstract: Hidden details of complex performance and only shows the performance required by the object.
Example (in Python)
class Animal:
def __init__(self, name):
self.name = name
def speak(self):
print("Animal speaks")
class Dog(Animal): # Inheritance
def speak(self): # Polymorphism
print(f"{self.name} says Woof!")
dog = Dog("Buddy")
dog.speak() # Output: Buddy says Woof!
The above example of python are mention .
We use cookies to enhance your experience, to provide social media features and to analyse our traffic. By continuing to browse, you agree to our Privacy Policy.
1 Answer
Umesh Sanjyal . 2 weeks ago
OPP programming (OOP) is a programming pattern based on the concept of "objects" that are examples of a class. These objects can contain data (properties) and code (methods) that work with data. Important Concepts OOP: Class: Design to create objects. Defines the features and methods that an object has. Object: An example of class. This represents a real -world creature with actions and countries. Encapsulation: You must hide the internal status of an object and do all the interactions using object methods. Inheritance: Allows one class to inherit the properties and behavior (methods) from another class. Poly Morphism: Even if they are in common with the same name, this method can behave differently based on the objects they call. Abstract: Hidden details of complex performance and only shows the performance required by the object. Example (in Python)
The above example of python are mention .