class Car {
}
class Maruti extends Car {
}
class Alto extends Maruti {
}
class Swift{}
public class TestMethodOverLoading1 {
static void printCar(Car c) {
System.out.print("A car is created");
}
static void printCar(Maruti m) {
System.out.println("A car name Maruti is created");
}
static void printCar(Object obj) {
System.out.println("Super Class is called");
}
public static void main(String args[]) {
Alto a = new Alto();
printCar(a); //method with maruti object will be called
Swift s = new Swift(); //superclass object will be called
printCar(s);
}
}