Encapsulation and data hiding

What is encapsulation and data hiding? Explain with example.
Are they same?

I don’t know y did u ask such a know question at this discussion session! Don’t you have a google? You can easily found the full and clear cut explanation at stackoverflow, quora, math.stackexchange like website. I am not saying that your question is wrong or you are spamming here. But i want to tell that You have to first search these type of doubts through these websites and then if you didn’t get satisfactory answer then you are free to ask question here.

Thank you!

They differ in a little sense of purpose in my opinion.

Data hiding is done to prevent unintended changes in and/or access to your application. While encapsulation is done to hide unnecessary information, which might confuse the user instead!

Please check detailed differences here

Encapsulation refer to the idea of binding data and method to a single unit called class . However there are two main criteria to bind data and methods . One of them is information hiding, just not the only one. To be perfectly concise i would say the two main criteria are

Data hiding means declaring data variables as private to secure it from unauthorized access but if you are giving some public setter and getter method for validation.

That’s not a right way to ask upvote. He will upvote or mark as accepted by their own!

1 Like

IDK, I saw people use that. Thanks for informing me though!! Edited.

yup! I also see some guys ask for vote or ask to mark accepted. I really hate these guys! These guys have only one intention to come in TOP 5 by answering the question and then wait for upvote or accepted answer.

1 Like

Thanks for telling me that. I certainly didn’t want to be termed with them! I thought it as something totally opposite!!