GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Concepts  >  OOPS
Go To First  |  Previous Question  |  Next Question 
 OOPS  |  Question 10 of 64    Print  
1.why do we need encapsulation?
2. what is a class in C++ analogous to in C



  
Total Answers and Comments: 6 Last Update: September 08, 2006     Asked by: harsha 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
November 10, 2005 13:44:33   #1  
diaupo@gmail.com Member Since: November 2005   Contribution: 1    

what is a class in C++ analogous to in C
struct.With C, you can .. struct { char fname[8]; char lname[16]; int age; } student;With Java, you canpublic class record{ public String fname; public String lname; public int age;}
 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
December 03, 2005 06:52:48   #2  
apiplani Member Since: December 2005   Contribution: 11    

RE: 1.why do we need encapsulation?2. what is a ...
This answer still didnt answer why do we need encapsulation. Well from wht I know we need encapsulation to ensure the data access is secure. We can control which are the variables of hte class which can be accessed and modified by the functions outside of the class and which are the variables which are private to the class.
 
Is this answer useful? Yes | No
December 09, 2005 03:09:01   #3  
pratiksha powar        

RE: 1.why do we need encapsulation?2. what is a ...

Analogue of C++ class in C:

We can have object-oriented implementation in C, by having a global function  which implements all the interfaces of an object.The particular function will use local data-structures and locally declared functions, which will be accessible only inside the gobal function not outside it.

The locally declared functions can be get-set methods or any sort of manipulation of the locally defined data-structure.

The global function itself acts like the  class.

The object creation and manipulation will be handled by this function alone.


 
Is this answer useful? Yes | No
February 01, 2006 08:19:40   #4  
sehlhorst Member Since: February 2006   Contribution: 8    

RE: 1.why do we need encapsulation?2. what is a ...
We need encapsulation to minimize the cost of maintaining the code. When we hide the internal structure of an object, we force other objects to talk to it through a specific API. This is contract based programming. Now we can test just this object (API inputs and inspect outputs) independently of other classes. We can also make changes to this class without affecting other parts of the software - because the changes are encapsulated to the single class.Also makes it easier for multiple people to work on the same project in parallel.
 
Is this answer useful? Yes | No
June 16, 2006 04:29:53   #5  
Raja Muthusamy        

RE: 1.why do we need encapsulation?2. what is a ...
In order to bind the data and functions working on it and to safegaurd our data and funtcions from outside access (access from the other objects) we need Encaptulations.
 
Is this answer useful? Yes | No
September 08, 2006 17:23:56   #6  
RAJEEV16706 Member Since: September 2006   Contribution: 7    

RE: 1.why do we need encapsulation?2. what is a ...

WELL DESIGNED MODULES ALWAYS HIDES ALL OF ITS IMPLEMENTAIONS DETAILS. MODULES THEN COMMUNICATE WITH EACH OTHER ONLY THROUGH API's UNKNOW TO EACH OTHER INNER IMPLEMENTATIONS

  • PROPER USE OF ACCESS MODIFIERS (PRIVATE,PUBLIC,PROTECTED) IS MUST FOR INFORMATION HIDING (ENCAPSULATION).
  • EACH MODULE COMPLETE BY ITSELF SO CAN PARALLELY DEVELOPED.
  • IT IS ALWAYS EASY TO DEBUG AND PERFORMANCE TUINING
  • ENCAPSULATION INCAREASE SYSTEM MODULE REUSE.
  • INFORMATION HIDING DECREASE THE RISK OF BUILDING LARGER SYSTEMS.

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape