Java Topics
Abstract Class
Last Updated : 26 May, 2026
title: Abstract Class in Java
title: Abstract Class in Java description: Abstract class ka concept aur use
Abstract class ek incomplete class hai. Object create nahi ho sakta. Child class extend karke complete karta hai.
Syntax
abstract class Shape {
String color;
Shape(String color) { this.color = color; }
// Abstract method — subclass implement karega
abstract double area();
abstract double perimeter();
// Concrete method
void displayColor() {
System.out.println("Color: " + color);
}
}Extend karna
class Circle extends Shape {
double radius;
Circle(String color, double radius) {
super(color);
this.radius = radius;
}
@Override
double area() { return Math.PI * radius * radius; }
@Override
double perimeter() { return 2 * Math.PI * radius; }
}
class Rectangle extends Shape {
double width, height;
Rectangle(String color, double w, double h) {
super(color);
this.width = w; this.height = h;
}
@Override
double area() { return width * height; }
@Override
double perimeter() { return 2 * (width + height); }
}Rules
abstractkeyword use karo- Abstract class ka object nahi banta
- Abstract methods ka body nahi hota
- Child class sabhi abstract methods implement kare (ya khud abstract ho)
- Constructor ho sakta hai
Use Case
Template Method Pattern mein use hota hai — common algorithm define karo, specific steps subclass mein.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Abstract Class.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Java topic.
Search Terms
java, java programming, core java, java master course, java notes, master, course, oops
Related Java Topics