Java Abstraction
Hiding the details of the object and showing the functionality is called as an abstraction.
In Java data abstraction refers to providing only essential information to the outside world and hiding the internal details.
Example: Phone call, we do not know the internal processing.

Advantages of Data Abstraction
- Implementation details of the class are protected from the unexpected user-level errors, which corrupt the state of the object.
- It helps to avoids the code duplication.
- It helps to reuse the code and provide partitioning of the code across the classes.
Abstract Class
A class which has declared as abstract is known as an abstract class. It has abstract methods and non-abstract methods. An abstract class consist of declaration as well as definition. It is a class that can't instantiated.
An abstract class is used as a base class for the deriving purpose only. An abstract class can't create an object.
abstract class A{ //Abstract methods //Non-Abstract methods }
Abstract Method
A method which has declared as abstract and it doesn't have implementation details is known as an abstract method.
abstract void method_name();//no method body
Example:
abstract class Shape // abstract class { abstract void draw(); } class Rectangle extends Shape { void draw() { System.out.println("Drawing of the rectangle"); } } class Circle extends Shape { void draw() { System.out.println("Drawing of the circle"); } } public class Abstractclass { public static void main(String args[]) { Shape s=new Circle(); Shape s1=new Rectangle(); s.draw(); s1.draw(); } }
Quickly Find What You Are Looking For
Onlinetpoint is optimized for basic learning, practice and more. Examples are well checked and working examples available on this website but we can't give assurity for 100% correctness of all the content. This site under copyright content belongs to Onlinetpoint. You agree to have read and accepted our terms of use, cookie and privacy policy.