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

What is the difference between the size and capacity of a vector?

794


What are keywords give examples?

808


What is the difference between Java Program Constructor and Java Program Method, What is the purpose of Java Program constructor Please Explain it Breafily?

830


Write a factorial program using recursion in java?

716


What are the library functions in java?

791


How do you check if an arraylist is not empty?

797


What is io stream in java?

748


What is static import in java?

734


What are keywords and reserved words in java?

795


How do I get 64 bit java?

725


When should I use stringbuffer?

786


What is keyword auto for?

898


What is the difference between superclass and subclass?

796


can used Protected Class outside Function.?

841


What are different types of arrays?

753