The purpose of inheritance is same for both Java and C++.
In Java classes are directly or indirectly inherited from Object hence there is always a single inheritance tree in Java.
In C++, there are multiple classes; when there is a class that doesn’t inherit from anything, there is a new tree created in forest.
Java doesn’t support multiple inheritance but C++ does. A class cannot inherit from more than one class in Java but a class can implement multiple interfaces though.