Top Posters
Since Sunday
25
10
9
6
w
3
M
3
C
2
l
2
2
s
2
2
2
New Topic  
Izaganag Izaganag
wrote...
Posts: 686
Rep: 2 0
6 years ago
"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
Textbook 

Java Software Solutions: Foundations of Program Design


Edition: 7th
Authors:
Read 316 times
4 Replies
Replies
Answer verified by a subject expert
habibtihabibti
wrote...
Top Poster
Posts: 1486
6 years ago
Sign in or Sign up in seconds to unlock everything for free
More questions for this book are available here
D
1

Related Topics

wrote...
6 years ago
Yeah, that works Slight Smile Thank you.
wrote...
6 years ago
Glad to help Slight Smile Slight Smile

PS I love how members in this community are so nice.
wrote...
A month ago
Thank you
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  127 People Browsing
 718 Signed Up Today
Related Images
 889
 437
 90