Differences in OOP
Differences in OOP
com with ❤️
ALL COMMONLY
ASKED DIFFRENCES IN
OBJECT ORIENTED
PROGRAMMING
Store.CodeWithCurious.com
For More Coding Books & Handwritten Notes © 2024 All Rights Reserved CodeWithCurious
Class vs Objects
Class Object
Defines properties (attributes) and Holds specific data and behaves as per
behaviors (methods). the class definition.
Not initialized with values, only defines Initialized with specific values for its
the structure. properties.
Curious_.Programmer
Encapsulation Vs Abstraction
Encapsulation Abstraction
Hiding internal data and allowing Hiding complex details and showing
access through methods. only important parts.
Ensures the integrity of the object's Allows working with complex systems
state by allowing controlled without needing to know how they work
modification. internally.
Curious_.Programmer
Overloading Vs Overriding
Must have different parameter lists Must have the same method signature
(number, type, or order). (name and parameters).
Curious_.Programmer
Interface Vs Abstract Class
A collection of abstract methods that a A class that can have both abstract
class must implement. and concrete (implemented) methods.
A class can implement multiple A class can extend only one abstract
interfaces. class (single inheritance).
Methods are public and cannot have Can have any access modifier (public,
any other access modifier. private, protected).
Cannot have instance variables (only Can have instance variables and
constants). constants.
Curious_.Programmer
Inheritance Vs Composition
Inheritance Composition
"Is-a" relationship (e.g., Dog is a type of "Has-a" relationship (e.g., Car has an
Animal). Engine).
Reuses code from the parent class by Reuses code by including objects of
extending it. other classes.
Less flexible, as the subclass is tightly More flexible, as classes are loosely
coupled with the superclass. coupled.
Copyright: CodeWithCurious.com
Use when you want to include
Use when there's a clear hierarchical
functionality from multiple classes
relationship.
without inheritance.
Curious_.Programmer