page contents
USA Real Estate Blog

Encapsulated Money? – Raja CSP Raman – Medium

0 4


Photo by Sharon McCutcheon on Unsplash

I know it’s too much when I ask Encapsulation in the interview of a junior developer because everyone knows that (Every developer candidate should know that)!

But when I ask about encapsulation, everyone shares blah blah blah from the Wiki or from the first 5 pages of DuckDuckGo search.

When I ask them like where do you see in your real life, they have no clue.

I am gonna explain a real-life encapsulation here!

Let’s assume you are a guy and you have a girlfriend (who likes lemon soda a much).

Your friend is coming to you and asks you for money. At the time you don’t have the money to give him (Of course, your bank, I mean your girlfriend has it and never shares the ATM pin).

In this case, you will always go to your girlfriend (with a lemon soda of course) ask her to shell out a bit and then forward the money to your friend.

Some kids might be asking, “Why not your friend directly goes to your girlfriend and ask for money (assuming you are a dummy in this financial transaction)?”

As an adult, you might know the reason so let’s not talk about it.

This is called Encapsulation!

In Java, we always use getter/setter methods to access the encapsulated variables. Accessing the variables directly is restricted by the Encapsulation rules.

That’s good for the programming and for your regular life as well (don’t you think?)

قالب وردپرس

You might also like

Leave A Reply

Your email address will not be published.

Pin It on Pinterest

Share This

Share this post with your friends!