Skip to content

supithcha/Inheritance-and-Interface-Implementation-Examples

Repository files navigation

Java Inheritance and Interface Implementation Examples

This project provides examples of Java classes that demonstrate the use of inheritance (extends) and interface implementation (implements). It serves as a learning resource for understanding how Java's object-oriented principles are applied in practice.

Features

  • Inheritance (extends): Shows how a subclass can inherit properties and methods from a superclass.
  • Interface Implementation (implements): Illustrates how classes can implement interfaces to define specific behaviors.
  • Practical Examples: Includes real-world scenarios to contextualize the use of inheritance and interfaces.

Project Structure

  • Area.java: Defines an interface for calculating the area of shapes.
  • ButterBall.java: A class that extends Ball and implements the Edible interface.
  • Circle.java: A class that extends Shape and implements the Area interface.
  • Edible.java: An interface that defines edible objects.
  • Main.java: The main class to run and test the examples.
  • Shape.java: An abstract class that serves as a superclass for various shapes.
  • Sphere.java: A class that extends Shape and implements the Area interface.

Contributing

Contributions are welcome! If you'd like to add more examples or improve the existing ones, please fork the repository and submit a pull request.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages