

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


1. Procedural vs. Object-Oriented Programming Procedural Programming: Focuses on functions and sequences of commands (e.g., C). Data and functions are separate, making large codebases harder to maintain. Object-Oriented Programming (OOP): Focuses on objects that combine both data (attributes) and behavior (methods). It mimics real-world entities, making code modular and reusable. 2. Core Building Blocks Class: A user-defined data type that acts as a blueprint, template, or contract for creating objects. It takes up no memory space until instantiated. Object: A basic runtime entity and an instance of a class. It occupies space in memory. Constructor: A special member function initialized automatically during object creation.
with custom values.
object.
3. The 4 Pillars of OOP (With Implementation Logic) A. Encapsulation The wrapping up of data and member functions into a single unit (Class). It enforces Data Hiding by keeping variables private and exposing them only through public methods. Java // Example in Java class Student {
private String name; // Private variable hidden from direct access // Public Getter public String getName() { return name; } // Public Setter public void setName(String newName) { this.name = newName; } } B. Abstraction Hiding complex implementation details and showing only the essential features to the user. Achieved using Abstract Classes (which can have abstract and concrete methods) or Interfaces (which define pure behaviors). C. Inheritance The process by which one class inherits the attributes and methods of another. Types: Single, Multilevel, Hierarchical, Multiple (supported via interfaces in Java/C#), and Hybrid. C++ // Example in C++ class Animal { public: void eat() { cout << "Eating..."; } }; class Dog : public Animal { // Dog inherits from Animal public: void bark() { cout << "Barking..."; } }; D. Polymorphism The ability of a single function or execution to manifest in multiple forms.