Saturday, Aug 8, 2026 · Practical tutorials, weekly

Abstraction | Java Abstraction OOPs | Abstract Class and Method

S Saurabh K Jul 13, 2020 1 min read 0 comments

Java Abstraction

— 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.

WATCH VIDEO:

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 abstract methods.

Abstraction Java Program:

abstract class Animal {
public abstract void animalSound();
public void sleep() {
System.out.println(“Zzz”);
}
}
class Pig extends Animal {
public void animalSound() {
System.out.println(“The pig says: wee wee”);
}
}
class MyAbstractClass {
public static void main(String[] args) {
Pig myPig = new Pig();
myPig.animalSound();
myPig.sleep();
}
}

Output: The pig says: wee wee , and Zzz

Java Abstraction OOPs

Connect with us:

Share:
Saurabh K

Saurabh K

Author at Technical Speaks

Writes practical guides and tutorials to help readers build, rank, and grow online.

Leave a Comment

Newsletter

Stay ahead of the curve

Join readers getting our freshest tutorials and guides on web, SEO, tech & more — delivered weekly.