Biology Forums - Study Force

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



Title: "class Aggregate" is incorrect. Choose the correct line so that this program printsGranite: weight=
Post by: Izaganag on Sep 21, 2015
"class Aggregate" is incorrect.  Choose the correct line so that this program prints
   Granite: weight=25.0 value=4 numKind=7

   public class Inherit
   {

      abstract class Stone
      {
         protected float weight = 13;
         protected int  value  = 4;
         abstract public String toString( );
      }

      class Aggregate
      {
         protected int numKind;
      }

      class Granite extends Aggregate
      {
         Granite( )
         {
            weight = 25; numKind = 7;
         }
         public String toString( )
         {
            return "Granite: weight="
               + weight + " value="
               + value  + " numKind="
               + numKind;
         }
      }

      Inherit( )
      {
         Granite g = new Granite( );
         System.out.println(g);
      }

      public static void main(String[ ] args)
      {
         new Inherit( );
      }
   }
A) class Aggregate extends Stone {
B) abstract class Aggregate {
C) abstract class Aggregate extends Granite {
D) abstract class Aggregate extends Stone {
E) none of the above


Title: Re: "class Aggregate" is incorrect. Choose the correct line so that this program printsGranite: wei
Post by: habibti on Sep 25, 2015
Content hidden


Title: Re: "class Aggregate" is incorrect. Choose the correct line so that this program printsGranite: weight=
Post by: Izaganag on Sep 28, 2015
Yeah, that works :) Thank you.


Title: Re: "class Aggregate" is incorrect. Choose the correct line so that this program printsGranite: weight=
Post by: habibti on Sep 28, 2015
Glad to help :) :)

PS I love how members in this community are so nice.