Object Oriented Programming

How to Code Inheritance in Java — Beginner’s Tutorial in OOP

Let’s understand the concept of ‘inheritance’ in object oriented programming

Rishi Sidhu
Towards Data Science
4 min readJan 10, 2020

--

Photo by Henry & Co. on Unsplash

Webster’s online dictionary defines inheritance as the acquisition of a possession, condition, or trait from past generations. In object oriented design inheritance has a similar (not exactly the same) connotation. Inheritance means

  1. Organising classes in a hierarchy
  2. Higher hierarchy inherits properties from lower hierarchy
  3. Clubbing similar things into the same class
  4. Classes go from general to specific as you go higher in hierarchy
How hierarchy looks like | Icons made by Pixel perfect from www.flaticon.com

This means that the most basic class, also known as the base class, will be the most general one. It is also known as the parent class or the super-class. For example ‘electronics’ is the base class and its child class will be ‘mobile phones’ or ‘sound systems’.

To know more about the basics of what constructs a class, details about fields, methods and constructors, you can refer to this article.

--

--