• Home
  • Java
    • Java Basics
  • Kafka
    • Producer
  • AWS
  • GoLang
  • About Me
mjpric3@gmail.com
Curriculum Vitae

The Code Standard

  • Home
  • Java
    • Java Basics
  • Kafka
    • Producer
  • AWS
  • GoLang
  • About Me

Inheritance

Basics

is one of the four pillars of Java. Its purpose is what it sounds like, to inherit some attributes and functionality from a super class or sometime referred to as “Parent” class to its child class. 

Benefit: 

  1. Allows us to share common code among sub-classes of the super class.
  2. Allows for more manageable code and refactoring.
  3. Allows for application to be more easily extendable.
  4. Maybe one of the most important things, is that it allows us to use Polymorphism. 

Example: An object is said to be a child if it has an “IS-A” Relationship with  another class. If it does, you may like to use the java keyword extends to inherit the fields and method of the super class. Here is a high-level example of some basic inheritance involving animals. Note that even though a Wolf and Dog extend the Canine class, they will inherit all attributes from the Canine class and the Mammal class. 

You also might be interested in

Conditional Statements

Dec 27, 2018

Conditional Statements are a core part of programming and everyday[...]

How To Write A Computer Program

Dec 22, 2018

Before writing any computer program you will need to choose[...]

Java Objects

Dec 22, 2018

Objects in Java An object in Java is a runtime[...]

Recent Posts

  • Producer
  • Interfaces
  • Abstraction
  • Polymorphism
  • Conditional Statements

Categories

  • Basics
  • Kafka
  • Welcome

© 2025 · thecodestandard.com

Prev Next