Core Java Tutorials


Introduction

Java Hello World

Java Compilation

JDK New Features

JVM Architecture

Java OOPs Concepts

Java Package

Array

Exception Handling

String

Immutable Class

File Handling

Serialization

MultiThreading

Volatile

Concurrent Package

Collection

Collection Internal

Generics

Cloning

Reflection In Java

Annotation

Class Loader

Java Inner classes

Garbage Collector

JDBC

References In Java

Heap Dump & Thread Dump

Inheritance in Java

Inheritance is a mechanism through which once class or object can inherits the attributes and behaviors of other class or object. Inheritance comes in the picture mainly when user wants to define common functionality or behaviors and he wants to use it across many implementations.

In Inheritance the class which define the command functionality is known as base class or super class and class which inherits the functionalities and attributes of base class is known as derived class or sub class.

Inheritance allows reusability of the code and inheritance is one of the feature of Object-Oriented Programming (OOPs).

Inheritance is a compile-time mechanism. A super-class can have any number of subclasses. But a subclass can have only one superclass. This is because Java does not support multiple inheritance.



Creating instance of Super class and Subclass



Super class reference an object of subclass