In Java, abstraction means showing only the important functionality and hiding the internal implementation details.
In simple terms:
You use something without needing to know how it works internally.
Real-life example
A fan:
You press the switch → fan turns on.
You don’t need to know how the motor and wiring work inside.
That’s abstraction.
Abstraction is usually implemented using:
abstract class
interface
Abstract class example
abstract class Vehicle {
abstract void start(); // abstract method
}
class Bike extends Vehicle {
void start() {
System.out.println("Bike starts with self-start");
}
}
public class Main {
public static void main(String[] args) {
Vehicle v = new Bike();
v.start();
}
}
Output
Bike starts with self-start
How abstraction works here
Vehicle defines what all vehicles should do:
every vehicle should have start()
But it does not say how.
The child class Bike gives the actual implementation.
So:
Parent class hides implementation details
Child class provides them
Why abstraction is used
hide unnecessary details
reduce complexity
improve security
make code easier to maintain
Simple explanation
Suppose:
Animal is abstract
Dog, Cat are concrete classes
All animals make sound, but each sound is different.
So:
abstract class Animal {
abstract void sound();
}
This tells every child class:
“You must implement your own sound.”
Key points
Abstract class cannot create objects directly
It may contain abstract and normal methods
Used to achieve abstraction
why abstract can't create objects
An abstract class cannot create objects because it is incomplete by design.
It may contain abstract methods — methods that are declared but have no implementation yet.
Example:
abstract class Animal {
abstract void sound();
}
Here sound() has no body. Java only knows:
the method name exists
but not what it should actually do
So if you tried to create an object:
Animal a = new Animal(); // error
Java would have a problem:
If someone calls a.sound(), what code should run?
There is no implementation yet.
That’s why Java blocks object creation for abstract classes.
Simple reason
An object should represent a fully usable thing.
But an abstract class is like a partial blueprint — it may still have unfinished parts.
So Java says:
complete class → object can be created
abstract class → object cannot be created directly
Real-life analogy
Think of a general idea like “Vehicle”.
A vehicle can:
start
stop
But “Vehicle” is just a general concept. You don’t buy a generic vehicle object in real life. You buy a specific:
Car
Bike
Same in Java:
Vehicle (abstract) → no object
Car, Bike (concrete subclasses) → object can be created
Example
abstract class Vehicle {
abstract void start();
}
class Car extends Vehicle {
void start() {
System.out.println("Car starts");
}
}
public class Main {
public static void main(String[] args) {
Vehicle v = new Car();
v.start();
}
}
Here:
Vehicle cannot create object
Car can, because it completes the abstract method
One-line answer
Abstract classes cannot create objects because they may contain incomplete methods, and Java requires an object to have complete behavior before it can be instantiated.
Top comments (0)