Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the max level of inheritance in java?

Tags:

java

oop

I was wondering if there is a finite number of time that I can inherit a class? Or what are the factors that can influence this?

like image 474
Rig Veda Avatar asked Oct 15 '10 08:10

Rig Veda


People also ask

How many levels of inheritance are allowed in Java?

On the basis of class, there can be three types of inheritance in java: single, multilevel and hierarchical. In java programming, multiple and hybrid inheritance is supported through interface only. We will learn about interfaces later.

How many levels of inheritance are there?

Single level inheritance: It will signify only two levels of classes. Base class and derived class. Multilevel inheritance: It will signify three or more levels of classes. Derived class, base class and one or more intermediate classes.

Is multi level inheritance possible in Java?

Java supports only Single, Multilevel, and Hierarchical types of inheritance. Java does not support Multiple and Hybrid inheritance.


2 Answers

Read this (Its fun)

The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
like image 91
pinichi Avatar answered Sep 17 '22 16:09

pinichi


For all practical applications, inheritance trees in Java may grow to infinite size.

like image 38
Jonathan Grynspan Avatar answered Sep 20 '22 16:09

Jonathan Grynspan