answersLogoWhite

0


Best Answer

By making fields private. That way, they can't be directly accessed from the outside - the are hidden, that is, encapsulated.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you achieve encapsulation by using class?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What does it mean by encapsulation?

Encapsulation makes class fields private, preventing access to it from outside of the class. Essentially, this data is hidden from the rest of the program. It is possible to allow access to the fields via public methods.


What is basic unit of encapsulation?

A Class. It encapsulates its variables and methods into it.


What is abstraction method in java?

Abstraction in Java or Object oriented programming is a way to segregate implementation from interface and one of the five fundamentals along with Encapsulation, Inheritance, Polymorphism, Class and Object. Abstraction in Java is achieved by using interface and abstract class in Java.


What is the name of the process of building a frame around network layer information?

Encapsulation. Actually, this is one type of encapsulation; encapsulation occurs at several layers.Encapsulation. Actually, this is one type of encapsulation; encapsulation occurs at several layers.Encapsulation. Actually, this is one type of encapsulation; encapsulation occurs at several layers.Encapsulation. Actually, this is one type of encapsulation; encapsulation occurs at several layers.


Are accessor member functions a sign of poor class design?

No, accessor member functions are a sign of good class design, particularly in terms of data encapsulation.


What term in java is used to indicate that a class's internal state is hidden from its clients?

Encapsulation............Hiding the data from others


What is the term that describes the hiding of implementation details of objects from each other in a C plus plus class?

Encapsulation.


Where the c plus plus encapsulation done?

There are no statements as such. Encapsulation is a design concept. The basic principal of encapsulation is that an object should contain all the information necessary to use the object, nothing more and nothing less. In other words, an object is a self-contained entity.


What are the oops concepts in net?

the 4 oops concept are: 1. Encapsulation: The process of wrapping data into a single unit is called Encapsulation 2. Inheritance: This the process in which a properties of a predefined class can be inherited in a new class making the object of that class in the making class. 3. Polymorphism: This the process in which a program can have more than one function with the same name but different parameters. 4. Data Hiding: It is the process of creating a logical insulation between the program and the environment.


What is different between inheritance and encapsulation?

wrapping up of data and function into a single unit is called encapsulation where polymorphism is the ability to take more than one form


How does a class in c plus plus enforce data encapsulation?

Data encapsulation is enforced by restricting access to the class members. Access can be specified on a per-member basis, defaulting to private access for a class and public access for a struct. Private members are accessible to class members and to friends of the class. Protected members are the same as private members but are also accessible to derived class members. Public members are fully-accessible. Data members are typically declared private while interfaces are typically declared public or protected.


Give an program on data encapsulation?

Encapsulation is the the hiding of code inside of Objects. The method of performing encapsulation practices is set in a Class's Meta Data inside of the class declaration. To be more specific the modifers of class attributes and methods can be either private or public.Example 1// Placing before the attribute declaration the public modifier allows this attribute to be// accessed by other objects or the main method.public int age;Example 2// Placing private before the attribute declaration prevents other object or the main method// from accessing the data.private int age;