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


Please Help Members By Posting Answers For Below Questions

What is the difference between Grid and Gridbaglayout?

825


What is the purpose of using break in each case of switch statement?

803


What happens if I remove static from main method?

790


Does printwriter create a file?

767


What is a line break example?

788


What is empty list in java?

850


What is an off by one error in java?

747


What are mutable classes?

754


How do I convert a string to an int in java?

818


What is the method overriding?

846


How do you sort data in java?

752


Where are register variables stored?

829


Does java support multiple inheritances?

819


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

773


What are the steps that are followed when two computers connect through tcp?

780