OOP Flashcards
What is OOP?
Object Oriented Programming is a programming paradigm based on the concepts of objects. These objects contain data in form of fields and procedures in form of methods.
4 basic principles of OOP
Encapsulation
Abstraction
Inheritence
Polymorphism
Encapsulation
It is a mechanism of restricting access to certain details of the object and only exposing the necessary parts through public methods.
Abstraction
Involves hiding the complex implementation details of a system and exposing only the essential features. It allows you to focus on what an object does rather than how it does it.
Done using Abstract classes and Inteface
Inheritance
Allows a new class (derived class or child class) to inherit properties and methods from an existing class (base class or parent class). This promotes code reuse and establishes a natural hierarchy between classes.
Polymorphism
Allows objects of different classes to be treated as objects of a common superclass. It is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.
Access Modifiers
Private - same file
Protected - derived classes any assembly
Internal - same assembly
Public - whole code base
Private Protected - derived classes same assembly
Protected Internal - same assembly and any derived classes