Nepedia
Back to Discover
Independent Reader
💻

Encapsulation (computer programming)

technology Maturity 7-9 Next article →

In computer programming, encapsulation is a way to organize code.

UML encapsulation
UML encapsulation

It has two main jobs. First, it bundles data together with methods. Methods are the tools that work on that data. This keeps all related parts in one place. It makes the code easier for people to read.

Second, encapsulation can hide certain parts of an object. This is often called information hiding. It stops other parts of the code from touching internal data. This protects the data from mistakes. If someone cannot touch the data directly, they cannot break it.

Programmers use special words to control this. In languages like Java or C++, they use words like public and private. A private part is hidden from the outside. A public part can be seen and used. This helps keep the whole system strong and simple.

Some systems use classes to do this. Other ways exist too, like using modules or libraries. Even some older ways of coding use these steps. Encapsulation helps programmers build big, complex systems without making too many mistakes.

173 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (1)
File:UML encapsulation.svg
UML encapsulation.svg
More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.