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 difference between Grid and Gridbaglayout?
What is the purpose of using break in each case of switch statement?
What happens if I remove static from main method?
Does printwriter create a file?
What is a line break example?
What is empty list in java?
What is an off by one error in java?
What are mutable classes?
How do I convert a string to an int in java?
What is the method overriding?
How do you sort data in java?
Where are register variables stored?
Does java support multiple inheritances?
can java object be locked down for exclusive use by a given thread? Or what happens when a thread cannot acquire a lock on an object? : Java thread
What are the steps that are followed when two computers connect through tcp?