Data Abstraction: Data abstraction is the concept of hiding the internal details of a class and showing only the essential features. This allows the user to interact with the object at a higher level without worrying about the underlying complexity. It is implemented in Java using abstract classes and interfaces.
Example:
abstract class Shape { abstract void draw(); // Abstract method } class Circle extends Shape { void draw() { System.out.println("Drawing a Circle"); } } class TestAbstraction { public static void main(String[] args) { Shape s = new Circle(); // Object of Circle class s.draw(); } }
In this example, Shape is an abstract class that hides the details of the draw() method. The Circle class provides the implementation, and the user only interacts with the draw() method.
First read the answer fully, then try to explain it in your own words. After that, open a few related questions and compare the concepts. This method helps you remember the topic for a longer time and improves exam preparation.