public interface Operation {
double add();
double subtract();
double multiply();
double divide();
}
The call is resolved by the compiler. It is achieved by function overloading and operator overloading.
public class Example {
public static int add(int a, int b) {
return a + b;
}
public static double add(double a, double b) {
return a + b;
}
public static void main(String args[]) {
System.out.println(add(2, 3));
System.out.println(add(2.0, 3.0));
}
}
Creating the subclass object with the help of superclass object.
abstract class Vehicle {}
class Car extends Vehicle {}
class Truck extends Vehicle {}
...
Vehicle car = new Car();
Vehicle truck = new Truck();