What is meant by Encapsulation? Can you write a class to
explain encapsulation?
Answer Posted / rajasekhar
It is the ability of an object to hide its data and methods
from the rest of the world.
A Class may contains a few members in the form of
properties,events,fields or methods.These members of the
class are not exposed to the outer world directly.Rather
they are ENCAPSULATED by the Class.
Public Class Calculations
{
Private void fnMultiply(int x, int y)
{
return x*y;
}
}
Calculations Obj;
int Result;
Result = Obj.fnMultiply(5,10);
| Is This Answer Correct ? | 19 Yes | 10 No |
Post New Answer View All Answers
What is a private class in java?
Why hashmap is used in java?
What is the most important feature of java? What is an interface?
Is java 9 released?
What are the differences between this and super keyword?
What is regex in java?
How many tetrahedral voids are there in bcc?
What is the purpose of lambda expressions?
What is Java Annotations?
How objects are stored in java?
How do you remove spaces in java?
What is functional interface in java?
If I don't provide any arguments on the command line, then what will the value stored in the string array passed into the main() method, empty or null?
Can interface be private in java?
Can an interface extend another interface?