Encapsulation
Encapsulation is an object-oriented programming principle that bundles data and the methods that operate on it within a single unit (a class), while restricting direct access to the object's internal state from outside code.
38 resources across 3 libraries
Glossary Terms(5)
Closures
A closure is a function that retains access to variables from the scope in which it was defined, even after that outer scope has finished executing.
Abstract Class
An abstract class is a class that cannot be instantiated directly and is designed to be subclassed, often providing shared implementation alongside one or more…
Polymorphism
Polymorphism is an object-oriented programming principle that allows objects of different classes to be treated through a common interface, with each object re…
Inheritance
Inheritance is an object-oriented programming mechanism that allows a class to acquire the properties and methods of another class, letting a subclass reuse an…
Encapsulation
Encapsulation is an object-oriented programming principle that bundles data and the methods that operate on it within a single unit (a class), while restrictin…
Study Notes(6)
Properties and Encapsulation
Understand how VB.NET Property blocks and Private fields work together to enforce encapsulation, validation, and controlled access to object state.
Encapsulation in Java
Learn how encapsulation in Java bundles data and behavior together using private fields, access modifiers, and getters/setters.
Encapsulation in Python
How Python bundles data and methods together and uses naming conventions and name mangling to signal restricted access.
Encapsulation in JavaScript
How JavaScript hides internal object state using ES2022 private class fields (`#field`) and the older underscore naming convention.
Encapsulation
How Python conventions for protected and private attributes, plus properties, let classes control access to their internal state.
Encapsulation and Access Modifiers
Understand how C#'s access modifiers — public, private, protected, internal, and their combinations — let you control visibility and enforce encapsulation boun…
Interview Questions(27)
Difference Between Abstraction and Encapsulation
Abstraction hides complexity by exposing only the essential behavior of an object, while encapsulation hides an object’s internal data by bundling it with the…
What are the Four Pillars of OOP?
The four pillars of object-oriented programming are Encapsulation, Abstraction, Inheritance, and Polymorphism — the principles that structure code around objec…
What is Encapsulation in OOP?
Encapsulation is the object-oriented principle of bundling an object’s data with the methods that operate on it and restricting direct access to that data from…
What is Abstraction in OOP?
Abstraction is the object-oriented principle of exposing only the essential features and behavior of an object while hiding the underlying implementation compl…
What is the Memento Pattern?
The Memento pattern captures and externalizes an object’s internal state so it can be restored later, without violating encapsulation by exposing that state’s…
What is the Anemic Domain Model Anti-Pattern?
An Anemic Domain Model is an object design where domain classes contain only fields and getters/setters with no real behavior, while all the business logic tha…
What Are Access Modifiers?
Access modifiers are keywords that control the visibility and accessibility of a class, method, or field — determining which other classes or packages are allo…
Public vs Private vs Protected
"public" members are accessible from any class anywhere, "private" members are accessible only within the declaring class itself, and “protected” members are a…
What is a Nested Class in OOP?
A nested class is a class defined entirely within the body of another class, used to logically group classes that are only meaningful in the context of their e…
What is an Inner Class in OOP?
An inner class is a non-static nested class that holds an implicit reference to an instance of its enclosing class, giving it direct access to that instance’s…
What is a Mutator Method in OOP?
A mutator method, commonly called a setter, is a public method that changes the internal state of an object in a controlled way, typically validating input bef…
What is an Accessor Method in OOP?
An accessor method, commonly called a getter, is a public method that returns the value of a private field without modifying the object’s internal state, provi…
Getters and Setters: Best Practices
Good getter/setter practice means not generating them blindly for every field, but instead validating input in setters, returning defensive copies of mutable f…
What is the Tell, Don’t Ask Principle?
Tell, Don’t Ask is the object-oriented design guideline that you should tell an object what to do by calling a method that performs the behavior internally, ra…
What is an Invariant in OOP?
A class invariant is a condition about an object’s state that must hold true at every point the object is observable from outside — after construction complete…
What is a Class Invariant?
A class invariant is a condition about an object’s internal state that must hold true before and after every public method call, guaranteeing the object is nev…
What is an Encapsulation Violation?
An encapsulation violation occurs when code outside a class can read or modify that class's internal state directly or indirectly, bypassing the validated publ…
What is Information Hiding?
Information hiding is the software design principle of concealing a module’s internal design decisions — data structures, algorithms, and implementation choice…
Information Hiding vs Encapsulation
Information hiding is the design-level principle of concealing decisions likely to change behind a stable interface, while encapsulation is the language-level…
What is a Friend Class in C++?
A friend class in C++ is a class explicitly granted access to another class’s private and protected members, declared using the `friend` keyword inside the cla…
Friend Functions vs Encapsulation
A friend function is a non-member function explicitly granted access to a class’s private and protected members, and it appears to conflict with encapsulation…
What is the OSI Model?
The OSI (Open Systems Interconnection) model is a conceptual framework that standardizes network communication into seven layers — Physical, Data Link, Network…
TCP/IP Model vs OSI Model
The OSI model is a seven-layer conceptual reference used for teaching and troubleshooting, while the TCP/IP model is a four-layer practical model that actually…
What is GRE (Generic Routing Encapsulation)?
GRE (Generic Routing Encapsulation) is a tunneling protocol that wraps one network-layer packet inside another, letting two endpoints carry traffic — including…
Showing 24 of 27.