Adding java 8 default examples

This commit is contained in:
NKaushik89
2018-10-02 22:11:17 +05:30
parent 2fc4b59b22
commit 3763010afc
5 changed files with 109 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
interface MyCar {
default public String getColor() {
return "red";
}
}
interface MyBike {
default public String getColor() {
return "blue";
}
}
public class MyVehicle implements MyCar, MyBike {
public static void main(String args[]) {
MyVehicle vehicle = new MyVehicle();
System.out.println(vehicle.getColor());
}
@Override
public String getColor() {
return MyCar.super.getColor();
}
}