1 2 Previous Next 22 Replies Latest reply on Aug 16, 2008 9:11 PM by 796440

    OO:overloading and overriding in tandem..Interesting one

      Assume Dog IS-A Animal

      class test {
      public static void main(String[] args){
      Animal a = new Dog();

      void foo(Dog d){

      void foo(Animal a){

      }//end of class test

      class Animal{
      void printme(){
      System.out.println("i am in animal");
      }//end of class animal

      class Dog{
      void printme(){
      System.out.println("i am in Dog");
      }//end of class dog
      Question:what will it print and explain how briefly u arrived at that result? (I assume u fix some obvious compile time errors(missing ; etc) as this is just a rough snippet)
      1.Overloading has to do with reference type
      2.Overriding has to do with the object to which it actually points
        1 2 Previous Next