× Didn't find what you were looking for? Ask a question
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  
Stromile Stromile
wrote...
Posts: 299
Rep: 0 0
5 years ago
Given the following code, 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.   abstract class Aggregate {
b.   abstract class Aggregate extends Granite {
c.   abstract class Aggregate extends Stone {
d.   class Aggregate extends Stone {
e.   None of these
Read 42 times
1 Reply
Replies
Answer verified by a subject expert
StingerStinger
wrote...
Posts: 310
Rep: 4 0
5 years ago
Sign in or Sign up in seconds to unlock everything for free
1

Related Topics

Stromile Author
wrote...

5 years ago
Correct Slight Smile TY
wrote...

Yesterday
This helped my grade so much Perfect
wrote...

2 hours ago
This site is awesome
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  1079 People Browsing
 115 Signed Up Today
Related Images
  
 413
  
 375
  
 262
Your Opinion
Which is the best fuel for late night cramming?
Votes: 145

Previous poll results: Where do you get your textbooks?