What is meant by Encapsulation? Can you write a class to
explain encapsulation?

Answer Posted / sivakishorereddy(badvel)

-Encapsulation is wrapping of data(Data members) and
associated methods(member functions) into a single unit in
such a way that data can be accessed with the help of
associated methods.
--In a class we can specify the variables(Data members) as
private. So for other classes it will not be accessible.
--Through methods(member functions) only we can access the
member variables or modify them.
--It gives more security for our data. It is nothing but
data hiding.

Is This Answer Correct ?    19 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can there be an abstract method without an abstract class?

541


What is not thread safe?

496


Can java run on google chrome?

574


What is run time allocation?

579


Differences between traditional programming language and object oriented programming language?

574






What is oops in java?

568


what do you mean by classloader in java?

576


Given a singly linked list, find the middle of the list in a single traversal without using temporary variable.

612


What are the differences between heap and stack memory?

554


What is the difference between numeric and integer?

513


Explain importance of finally block in java?

586


What is ascii code?

645


What one should take care of, while serializing the object?

484


What is java english?

496


How we can execute any code even before main method?

555