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 the maximum size of hashmap in java?
What does exclamation mean in java?
What does singleton mean in java?
Can you override a final method?
Can a source file contain more than one class declaration?
Can you explain the final method modifier?
What is a method in coding?
What is meant by class loader? How many types are there?
What is a byte string?
What is the difference between iterator and enumeration ?
What is use of super keyword in java?
Can a class be private?
Can you extend singleton class?
How can you generate random numbers in java?
What is the use of default method in interface in java?