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

Is java hard to learn?

721


What is a singleton puppy?

759


What is the exact difference in between Unicast and Multicast object?

1804


What is the name of the java compiler?

817


How are the elements of a gridbaglayout organized?

821


What are thread priorities and importance of thread priorities in java?

848


What is udp in java?

775


What is polymorphism and what are the types of it?

732


How big is a gigabyte?

849


How is abstraction implemented in java ?

745


How to perform selection sort in java?

819


When throws keyword is used?

779


Is the milky way in a void?

782


How to avoid memory leak in java?

863


What is defined as false sharing in the context of multithreading?

798