answersLogoWhite

0

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.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Why encapsulation is needed in java?

Encapsulation is not needed in Java, or any other language. But it's useful. Encapsulation is used to minimise the number of potential dependencies with the highest probability of change propagation.


What is abstraction method in java?

Abstraction in Java or Object oriented programming is a way to segregate implementation from interface and one of the five fundamentals along with Encapsulation, Inheritance, Polymorphism, Class and Object. Abstraction in Java is achieved by using interface and abstract class in Java.


How data hiding is achieved in java?

Data hiding in the java is achieved through the use of encapsulation.


How can find the length of a string in java without using fun?

Use length() method. Example: "java".length();


Why java is called truly object oriented language?

because java supports three main pillars.....(inheritance encapsulation and abstraction)..... and everything in java is OBJECT......


Why java do not support global variable declaration?

in order to acheive a inheritance and data encapsulation property global variables are not declared in java.


Can you run a java programme in atom processor?

no


What is overriding method in java with simple example?

ye bohut mushkil sawa lhai


What is overridnig method and overlording method in java?

There is no such thing as overlording in Java.


Why java know as true object oriented language?

Java is not a true object-oriented language.One of the requirements for such a title is that everything must be an object. Java contains non-object primitive values (such as int, float, boolean, etc.).


What method that returns string representation of the contents of the variable?

Since the question is in the Java category: in Java, the method is called toString(). This method will automatically be invoked if you implicitly convert an object to String type, for example: "The answer is: " + myObject In this example, the String concatenation (the plus sign) forces the object, myObject, to type String - to do this, the object's toString() method will be called.


What are the features of core java?

Core java refers to the core or basic concepts of the Java programming language. Things like encapsulation, inheritance, multi-threading, exception handling and other basic feature of java that comes as part of the Java standard edition forms Core Java