All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java8.AboutMultipleInheritance Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
package java8;

import com.sandwich.koan.Koan;

import static com.sandwich.koan.constant.KoanConstants.__;
import static com.sandwich.util.Assert.assertEquals;

public class AboutMultipleInheritance {

    interface Human {
        default String sound() {
            return "hello";
        }
    }

    interface Bull {
        default String sound() {
            return "moo";
        }
    }

    class Minotaur implements Human, Bull {
        //both interfaces implement same default method
        //has to be overridden
        @Override
        public String sound() {
            return Bull.super.sound();
        }
    }

    @Koan
    public void multipleInheritance() {
        Minotaur minotaur = new Minotaur();
        assertEquals(minotaur.sound(), __);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy