Java Question:OOP
In what way is Data Hiding and Data Abstraction related?
Please send correct answer..
Answers
Explanation:
What is Abstraction in Java?
Abstraction in JAVA “shows” only the essential attributes and “hides” unnecessary details of the object from the user. In Java, abstraction is accomplished using Abstract classes, Abstract methods, and interfaces. Abstraction helps in reducing programming complexity and effort.
Abstract Class
A class which is declared “abstract” is called as an abstract class. It can have abstract methods as well as concrete methods. A normal class cannot have abstract methods.
Abstract Method
A method without a body is known as an Abstract Method. It must be declared in an abstract class. The abstract method will never be final because the abstract class must implement all the
Data hiding is a process of combining data and functions into a single unit. The ideology behind data hiding is to conceal data within a class, to prevent its direct access from outside the class. It helps programmers to create classes with unique data sets and functions, avoiding unnecessary penetration from other program classes.
Discussing data hiding & data encapsulation, data hiding only hides class data components, whereas data encapsulation hides class data parts and private methods.
Now you also need to know access specifier for understanding data hiding.
private, public & protected are three types of protection/ access specifiers available within a class. Usually, the data within a class is private & the functions are public. The data is hidden, so that it will be safe from accidental manipulation.
Private members/methods can only be accessed by methods defined as part of the class. Data is most often defined as private to prevent direct outside access from other classes. Private members can be accessed by members of the class.
Public members/methods can be accessed from anywhere in the program. Class methods are usually public which is used to manipulate the data present in the class. As a general rule, data should not be declared public. Public members can be accessed by members and objects of the class.
Protected member/methods are private within a class and are available for private access in the derived class.
Answer:
mark me as the brain list answer
Explanation:
Abstraction is a method of expressing the important properties without involving the background details. On the other hand, Data hiding insulates the data from the straight access by the program. Although, both the concepts sound similar in the sense but are different