Top Posters
Since Sunday
g
3
3
2
J
2
p
2
m
2
h
2
s
2
r
2
d
2
l
2
a
2
New Topic  
Izaganag Izaganag
wrote...
Posts: 686
Rep: 2 0
8 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

Java Software Solutions: Foundations of Program Design


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

Related Topics

Izaganag Author
wrote...
8 years ago
Yeah, that works Slight Smile Thank you.
wrote...
8 years ago
Glad to help Slight Smile Slight Smile

PS I love how members in this community are so nice.
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  568 People Browsing
 125 Signed Up Today
Related Images
  
 62
  
 338
  
 709
Your Opinion
Who will win the 2024 president election?
Votes: 3
Closes: November 4

Previous poll results: Where do you get your textbooks?