In java they are saying that class can not be inherited by multiple super classes. Only can be one. See this code,
Animal.java
public class Animal { }
Dog.java
public class Dog extends Animal{
public static void main(String[] args) {
Animal animal = new Animal();
Dog bulldog = new Dog();
Dog rottweiler = new Dog();
if (bulldog.equals(rottweiler)) {
System.out.println("animal == bulldog");
}else {
System.out.println("animal != bulldog");
}
} }
Hear We can see that Dog class is inheriting from Animal. But I am using equals method which belongs to Object class in java. In SCJP book they are saying that each and every class in java is a subclass of Object class. Yes..! That is why I am able to use methods like equals in Dog class. Then my question is, aren't we unknowingly using multiple inheritance in java? Why because we are inheriting from Object and Animal classes to Dog class?