1
abstract class Bike{
  abstract void run();
}

class Honda extends Bike{
  void run(){
    System.out.print("running");
  }
  public static void main(String args[]){
    Bike obj=new Honda(); //Upcasting
    obj.run();
  }
}

We could have get the same result using

Honda obj=new Honda();
obj.run();

why use upcasting? If we can get the same results?

alzee
  • 1,393
  • 1
  • 10
  • 21
user6664723
  • 23
  • 1
  • 6

0 Answers0