+ 2
multiple inheritance example using interface?
i need a small & complete example of inheritance using interface(Multiple inheritance)...i'm a beginner in java so, Please help me to write a basic example and syntax of the same..
1 ответ
+ 15
Syntax :
public interface A{
//Do Something
}
public interface B extends A{
//Do Something
}
public interface C extends A{
//Do Something
}
Multiple Inheritance Using Interface Example Program
interface vehicleone{
int speed=90;
public void distance();
}
interface vehicletwo{
int distance=100;
public void speed();
}
class Vehicle implements vehicleone,vehicletwo{
public void distance(){
int distance=speed*100;
System.out.println("distance travelled is "+distance);
}
public void speed(){
int speed=distance/100;
}
}
class MultipleInheritanceUsingInterface{
public static void main(String args[]){
System.out.println("Vehicle");
obj.distance();
obj.speed();
}
}