.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
satyapriyanayak
abhays
SP
Ashutosh Jha
Mahesh

Home >> Forum >> OOPS >> Post New QuestionBookmark and Share Subscribe to Forum

Example for encapsulation

Posted By: Karthikeyan Anbarasan     Posted Date: December 30, 2010    Points:2   Category :OOPS
Can any one give me real time example for Encapsulation

Responses
Author: Gautam Kanaujia          Accepted Answer   
Posted Date: December 31, 2010     Points: 10   


Encapsulation can be easily understood by the below real time examples:

Example No 1:
Data encapsulation is a technique used to protect the information in an object from the other object.

real time example : TV operation
it is encapsulated with cover and we can operate with remote and no need to open TV and change the channel. here everything is in private except remote so that any one can access not to operate and change the things in TV

Example No 2:
Data Encapsulation tecnique is only used with Object Oriented Programming, in this technique a class is having object(s) which only gives the functionality of that class but not the detail of the procedure followed by the function in the class.
Let's take example of Car and Car Manufacturer
Suppose you are a Car Manufacturer and you designed and developed a car design(class), now by using machinery you are manufacturing a car(object) for selling, when you sell your car the user only learn how to use the car but not that how this car works.
This means that You are creating the class with function and by making object(capsule) of it you are making availability of the functionality of you class by that object and without the interference in the original class.

Now some Programming level discription:
All the OOP programming languages such as C++, C#, Java
etc is having a concept of class and instance/object of a class, you can implement encapsulation by creating a class with some
functions and then create the object of that class, and acess the functionality of the functions of that class through object of that
class.

All this is encapsulation and this is most basic property of a object oriented programming paradigm.

Note: Encapsulation is only, can be used in Object Oriented Programming Paradigm, not in non-OOP paradigm.




Author: Karthikeyan Anbarasan       [Moderator]      
Posted Date: December 31, 2010     Points: 5   

Nice examples... thanks

Thanks
Karthik
http://www.f5debug.net
Mark as Answer if the answer solves your issue!!!
Author: shishir             
Posted Date: January 03, 2011     Points: 5   

Great job Gautam...
Keep it up

Author: duraikannan             
Posted Date: January 22, 2011     Points: 5   

* The Data Encapsulation is one of the piller of OOPs.
* Putting data and related function in a class called as "Data Encapsulation".

Author: Vinodh             
Posted Date: September 18, 2011     Points: 20   

An object is nothing when it doesn't encapsulate data/behavior (class members)
Car is an object which encapsulates brek,seat,mirror/speed,acceleration etc

Author: Pankaj Chahar             
Posted Date: November 26, 2011     Points: 20   

Hi,

Encapsulation:-
-is nothing but wrapping the data and functions into single entity.


Example
cars and owners...
all the functions of cars are encapsulated with the owners..
No one else can access it...




Pankaj Chahar

Deserve More





Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend