Biology Forums - Study Force

Science-Related Homework Help Computer Studies Topic started by: Izaganag on Sep 21, 2015



Title: What is printed by the following code?public class Inherit{ abstract class Speaker{abstract public v
Post by: Izaganag on Sep 21, 2015
What is printed by the following code?
   public class Inherit
   {

      abstract class Speaker
      {
         abstract public void speak( );
      }
      class Cat extends Speaker
      {
         public void speak( )
         {
            System.out.println("Woof!");
         }
      }

      class Dog extends Speaker
      {
         public void speak( )
         {
            System.out.println("Meow!");
         }
      }

      Inherit( )
      {
         Speaker d = new Dog( );
         Speaker c = new Cat( );
         d.speak( );
         c.speak( );
      }

      public static void main(String[ ] args)
      {
         new Inherit( );
      }
   }
A) Meow!
Woof!
B) Woof!
Meow!
C) Woof!
Woof!
D) Meow!
Meow!
E) none of the above


Title: Re: What is printed by the following code?public class Inherit{ abstract class Speaker{abstract publ
Post by: habibti on Sep 25, 2015
Content hidden


Title: Re: What is printed by the following code?public class Inherit{ abstract class Speaker{abstract public v
Post by: Izaganag on Sep 28, 2015
That makes life a whole lot easier, thank you for answering.


Title: Re: What is printed by the following code?public class Inherit{ abstract class Speaker{abstract public v
Post by: habibti on Sep 28, 2015
Guys, you see that "vote as best answer" button below the answer, CLICK IT :) :)