Abstraction in Java is a core concept of Object-Oriented Programming (OOP). It means hiding unnecessary implementation details and showing only the essential features of an object.
Abstraction focuses on what an object does instead of how it does it.
Example:
When you drive a car, you use the steering wheel, accelerator, and brakes — you don’t need to know how the engine works internally.
How Abstraction is Achieved in Java
In Java, abstraction is implemented using:
Abstract Classes
Declared using the keyword abstract
Can have:
Abstract methods (no body)
Concrete methods (with body)
abstract class Animal { abstract void sound (); // abstract method
void eat () { System . out . println ( "This animal eats food" ); } }
class Dog extends Animal { void sound () { System . out . println ( "Dog barks" ); } }
Enter fullscreen mode
Exit fullscreen mode
2.…