Skip to content

A simple Java project demonstrating the use of abstract classes and method overriding through geometric shapes like Circle and Rectangle. Includes implementations of area and perimeter calculations using inheritance and abstraction principles.

Notifications You must be signed in to change notification settings

Ankit0830/JavaAbstractClassExample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Java Abstract Class Example - Shapes

This Java project demonstrates the concept of abstract classes and method overriding using geometric shapes like Circle and Rectangle. The program uses abstraction to define a common interface (Shape) and allows subclasses to provide specific implementations for calculating the area and perimeter.

πŸ“ Package Structure

AbstractEx.java

πŸ“Œ Features

  • Abstract class Shape with two abstract methods:

    • double perimeter()
    • double area()
  • Concrete classes:

    • Circle: Implements perimeter and area using radius.
    • Rectangle: Implements perimeter and area using length and breadth.
  • Demonstrates:

    • Abstraction
    • Inheritance
    • Method Overriding
    • Polymorphism (by assigning Circle to a Shape reference)

πŸ§ͺ Output

The Perimeter of Circle: 65.97344572538566 The Area of Circle: 346.3605900582747 Accessing Circle Area using Shape reference: 346.3605900582747 The Perimeter of Rectangle: 60.0 The Area of Rectangle: 200.0

About

A simple Java project demonstrating the use of abstract classes and method overriding through geometric shapes like Circle and Rectangle. Includes implementations of area and perimeter calculations using inheritance and abstraction principles.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages