what is meant by Encapsulation?Explain with an example?
Answer Posted / santhosh kandula
Encapsulation is nothing but hiding the data.By using
encapsulation the ability to modify the code without
without breaking the code the other who use our code. In
Encapsulation we have to pass private members and access
via the public modifiers.
Example : public class EncapsDemo
{
private String str;
public String getString()
{
return str;
}
public void setString(String str)
{
this.str=str;
}
}
| Is This Answer Correct ? | 2 Yes | 2 No |
Post New Answer View All Answers
What is the difference between a jdk and a jvm?
Why doesn't lsdou work under windows nt? : java security
When do we go for java 8 stream api? Why do we need to use java 8 stream api in our projects?
In java what is the difference between sleep() and wait() .
What is savepoint in java?
What is java lang noclassdeffounderror?
Why sun introduce concept of anonymous class? What is need and real life use of anonymous class
Which instutute is offering course for rhino jain slee
When a thread is created and started, what is its initial state?
Where is singleton design pattern used in java?
What is a yaml file in java?
What is a container in java?
What is type inference? Is type inference available in older versions like java 7 and before 7 or it is available only in java se 8?
What is gui in java with examples?
How do you count in java?