answersLogoWhite

0

Functions of encapsulation

Updated: 10/3/2023
User Avatar

Wiki User

13y ago

Best Answer

The ability to make changes in your code without breaking the code of all others who use your code is a key benefit of encapsulation. You should always hide implementation details. To elaborate, you must always have your variables as private and then have a set of public methods that others can use to access your variables. Since the methods are public anyone can access them, but since they are in your class you can ensure that the code works the way that is best for you. So in a situation that you want to alter your code, all you have to do is modify your methods. No one gets hurt because i am just using your method names in my code and the code inside your method doesnt bother me much.

If you want maintainability, flexibility, and extensibility (and I guess, you do), your design must include encapsulation. How do you do that?

• Keep instance variables protected (with an access modifier, mostly private).

• Make public accessor methods, and force calling code to use those methods rather than directly accessing the instance variable.

• For the methods, use the JavaBeans naming convention of set and get.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

 identifies pieces of data as part of the same communication  ensures that data pieces can be directed to the correct receiving end device  enables the reassembly of complete messages  identifies pieces of data as part of the same communication  ensures that data pieces can be directed to the correct receiving end device  enables the reassembly of complete messages

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Identifies pieces of data as part of the same communication. Ensures that data pieces can be directed to the correct receiving end device. Enables the reassembly of complete messages

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Functions of encapsulation
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Are accessor member functions a sign of poor class design?

No, accessor member functions are a sign of good class design, particularly in terms of data encapsulation.


What primary three functions does data link layer encapsulation provide?

* addressing * error detection * frame delimiting


What are the three primary functions provided by Layer 2 data encapsulation?

Primary functions provided by Layer 2 data encapsulation include data link layer addressing, and the detection of errors via cyclic redundancy check calculations. An additional function is delimiting groups of bits into frames.


Can abstraction encapsulation be achieved in C program if yes explain?

abstraction and encapsulation is one of the concepts of OOPs and C is not an OOP [Object Oriented Programming language] obviously abst & encap will not be supported by 'C' Abstraction & encapsulation is a concept of OOP [Object Oriented Programming] But, 'C' is not an OOP whereas it is a POP [Procedure oriented programming], so obviously 'C' does not support abstraction and encapsulation Answer Encapsulation is not inherently supported but it can be emulated in C. The use of static and extern keywords for functions are almost equivalent to your private and public keywords in java (encapsulation). Read up more on those keywords.. Structures become an object's attributes while functions accepting pointers the the said struct become its methods.


What is the name of the process of building a frame around network layer information?

Encapsulation. Actually, this is one type of encapsulation; encapsulation occurs at several layers.Encapsulation. Actually, this is one type of encapsulation; encapsulation occurs at several layers.Encapsulation. Actually, this is one type of encapsulation; encapsulation occurs at several layers.Encapsulation. Actually, this is one type of encapsulation; encapsulation occurs at several layers.


What the functions of encapsulation?

a) Identifies pieces of data as part of the same communication b) Ensures that data pieces can be directed to the correct receiving end devices


What are oop functions?

1.genericity 2.polymorphism 3.objects and classes 4.data abstraction 5.data encapsulation 6.inheritence


Which command sets the encapsulation on a Serial interface back to the Cisco default?

encapsulation hdlc


What is an object in programming terminology?

programming objects are used to store variables (fields) which can be accessed or manipulated through the use of methods or functions. Objects are used as a means of data encapsulation.


What is encapsulation in net?

Encapsulation is the ability to hide its data and methods from outside the world and only expose data and methods that are required


3 pillars of object oriented programming?

abstraction, inheritance, encapsulation, and polymorphism.


What are two switching functions of a router?

The router encapsulates the packet in the appropriate data link frame type for the outgoing data link. The router determines the exit interface after data encapsulation.