answersLogoWhite

0


Best Answer

Abstraction

Abstraction is simplifying complex reality by modelling classes appropriate to the problem, and working at the most appropriate level of inheritance for a given aspect of the problem.

For example, Lassie the Dog may be treated as a Dog much of the time, a Collie when necessary to access Collie-specific attributes or behaviors, and as an Animal (perhaps the parent class of Dog) when counting Timmy's pets.

Abstraction is also achieved through Composition. For example, a class Car would be made up of an Engine, Gearbox, Steering objects, and many more components. To build the Car class, one does not need to know how the different components work internally, but only how to interface with them, i.e., send messages to them, receive messages from them, and perhaps make the different objects composing the class interact with each other.

Encapsulation

Encapsulation conceals the functional details of a class from objects that send messages to it.

For example, the Dog class has a bark() method. The code for the bark() method defines exactly how a bark happens (e.g., by inhale() and then exhale(), at a particular pitch and volume). Timmy, Lassie's friend, however, does not need to know exactly how she barks. Encapsulation is achieved by specifying which classes may use the members of an object. The result is that each object exposes to any class a certain interface - those members accessible to that class. The reason for encapsulation is to prevent clients of an interface from depending on those parts of the implementation that are likely to change in future, thereby allowing those changes to be made more easily, that is, without changes to clients. For example, an interface can ensure that puppies can only be added to an object of the class Dog by code in that class. Members are often specified as public, protected or private, determining whether they are available to all classes, sub-classes or only the defining class. Some languages go further: Java uses the default access modifier to restrict access also to classes in the same package, C# and VB.NET reserve some members to classes in the same assembly using keywords internal (C#) or Friend (VB.NET), and Eiffel and C++ allow one to specify which classes may access any member.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Data abstraction and encapsulation in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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.


How data hiding is achieved in java?

Data hiding in the java is achieved through the use of encapsulation.


3 pillars of object oriented programming?

abstraction, inheritance, encapsulation, and polymorphism.


Why java do not support global variable declaration?

in order to acheive a inheritance and data encapsulation property global variables are not declared in java.


Can abstraction encapsulation be achieved in C program if yes explain?

abstraction and encapsulation is one of the concepts of OOPs and C is not an OOP [Object Oriented Programming language] obviously abst & encap will not be supported by 'C' Abstraction & encapsulation is a concept of OOP [Object Oriented Programming] But, 'C' is not an OOP whereas it is a POP [Procedure oriented programming], so obviously 'C' does not support abstraction and encapsulation Answer Encapsulation is not inherently supported but it can be emulated in C. The use of static and extern keywords for functions are almost equivalent to your private and public keywords in java (encapsulation). Read up more on those keywords.. Structures become an object's attributes while functions accepting pointers the the said struct become its methods.

Related questions

What are basic java features?

features are: 1. Inheritance 2. Polymorphism 3. Data Encapsulation 4. Data Abstraction etc..


What are the characteristics of OOPS?

Data Encapsulation, Abstraction, Inheritance, Polymorphism


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.


Some important features of java programming?

The important features of Java are the ones that relate to the object oriented concepts like: a. Inheritance b. Polymorphism c. Encapsulation d. Data Hiding e. Data Abstraction etc


Why java is called truly object oriented language?

because java supports three main pillars.....(inheritance encapsulation and abstraction)..... and everything in java is OBJECT......


How data hiding is achieved in java?

Data hiding in the java is achieved through the use of encapsulation.


What are basic features?

features are: 1. Inheritance 2. Polymorphism 3. Data Encapsulation 4. Data Abstraction etc..


What is data abstraction in c sharp?

Abstraction means that all information exist but only the relevent information is provided to the user. Encapsulation assists abstraction by providing a mean of suppressing the non-essential details.


3 pillars of object oriented programming?

abstraction, inheritance, encapsulation, and polymorphism.


What are functionalities of OOPS?

1.genericity 2.polymorphism 3.objects and classes 4.data abstraction 5.data encapsulation 6.inheritence


What are oop functions?

1.genericity 2.polymorphism 3.objects and classes 4.data abstraction 5.data encapsulation 6.inheritence


Why java do not support global variable declaration?

in order to acheive a inheritance and data encapsulation property global variables are not declared in java.