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

Explain about instanceof operator in java?

811


What are the three parts of a lambda expression? What is the type of lambda expression?

817


What is jit compiler in java?

801


How do I enable java in safari?

782


Does java isempty check for null?

782


Justify your answer that you can't define a method inside another method in java, if you can then how?

813


How to disable caching on back button of the browser?

756


Is 0 an irrational number?

822


What are different ways of object creation in java ?

789


What is volatile keyword in java

881


How can an exception be thrown manually by a programmer?

738


What is command line argument in java?

850


Why javac is not recognized?

719


What is instance example?

724


Difference between error and exception

5479