Computer Science, asked by Sarim666, 5 months ago

What is an example of data abstraction in Java?​

NO ANSWERS FROM GOOGLE PLZ​

Answers

Answered by MissPhenomenal
6

\huge \purple A \purple N \purple s \purple W \purple e \purple \R:-

Data Abstraction is the property by virtue of which only the essential details are displayed to the user.The trivial or the non-essentials units are not displayed to the user. Ex: A car is viewed as a car rather than its individual components.

Data Abstraction may also be defined as the process of identifying only the required characteristics of an object ignoring the irrelevant details.The properties and behaviors of an object differentiate it from other objects of similar type and also help in classifying/grouping the objects.

Consider a real-life example of a man driving a car. The man only knows that pressing the accelerators will increase the speed of car or applying brakes will stop the car but he does not know about how on pressing the accelerator the speed is actually increasing, he does not know about the inner mechanism of the car or the implementation of accelerator, brakes etc in the car. This is what abstraction is.

In java, abstraction is achieved by interfaces and abstract classes. We can achieve 100% abstraction using interfaces.

Abstract classes and Abstract methods :

  • An abstract class is a class that is declared with abstract keyword.
  • An abstract method is a method that is declared without an implementation.
  • An abstract class may or may not have all abstract methods. Some of them can be concrete methods
  • A method defined abstract must always be redefined in the subclass,thus making overriding compulsory OR either make subclass itself abstract.
  • Any class that contains one or more abstract methods must also be declared with abstract keyword.
  • There can be no object of an abstract class.That is, an abstract class can not be directly instantiated with the new operator.
  • An abstract class can have parametrized constructors and default constructor is always present in an abstract class.

When to use abstract classes and abstract methods with an example

There are situations in which we will want to define a superclass that declares the structure of a given abstraction without providing a complete implementation of every method. That is, sometimes we will want to create a superclass that only defines a generalization form that will be shared by all of its subclasses, leaving it to each subclass to fill in the details.

Answered by Kristy12
7

Answer:

Abstraction is a technique of hiding unnecessary details from the user. The user is only given access to the details that are relevant. ... Java provides abstraction through abstract classes and interfaces. While interfaces provide 100 % abstraction, abstract classes provide partial abstraction.

Explanation:

Small help from u ‼️

10 Thanks please ❤️

Similar questions