Abstract class program
Write a java program to create an abstract class named Shape that contains two integers and an empty method named printArea(). Provide three classes named Rectangle, Triangle and Circle such that each one of the classes extends the class Shape. Each one of the classes contain only the method printAr
Abstract class program
JAVA videos
Write a java program to create an abstract class named Shape that contains two integers and an empty method named printArea(). Provide three classes named Rectangle, Triangle and Circle such that each one of the classes extends the class Shape. Each one of the classes contain only the method printArea( ) that prints the area of the given shape.
abstract class Shape
{
int a, b;
abstract void printArea();
}
class Rectangle extends Shape
{
public Rectangle(int x, int y)
{
a = x;
b = y;
}
public void printArea()
{
System.out.println("Rectangle Area => " + (a * b));
}
}
class Triangle extends Shape
{
public Triangle(int x, int y)
{
a = x;
b = y;
}
public void printArea()
{
System.out.println("Triangle Area => " + (0.5 * a * b));
}
}
class Circle extends Shape
{
public Circle(int x)
{
a = x;
}
public void printArea()
{
System.out.println("Circle Area => " + (3.14 * a * a));
}
}
public class Practical19{
public static void main(String[] args)
{
Rectangle R = new Rectangle(10,20);
Triangle T = new Triangle(5,10);
Circle C = new Circle(8);
R.printArea();
T.printArea();
C.printArea();
}
}
Interface program
Related Posts
Continue learning with these related articles

Logic Gates for ISC Class 11: Truth Tables, Universal Gates, Half and Full Adder
ISC Class 11 Computer Science notes on logic gates: AND, OR, NOT, NAND, NOR, XOR and XNOR with truth tables, why NAND and NOR are universal gates, and half adder and full adder circuits with their Boolean expressions.
Decimal to Binary Conversion in Java: 3 Programs with Examples
How to convert a decimal number to binary on paper and in Java: three programs (String, place value and Integer.toBinaryString), binary to decimal, a dry run and common mistakes.

ISC Class 11 Computer Science Sample Paper 2026-27 with Solutions
A full 70-mark ISC Class 11 Computer Science sample paper for the 2026-27 annual exam: MCQs, number systems, propositional logic, logic gates, Java classes, arrays, strings, searching and sorting, and computing ethics, with complete worked solutions.