× Didn't find what you were looking for? Ask a question
Top Posters
Since Sunday
5
a
5
k
5
c
5
B
5
l
5
C
4
s
4
a
4
t
4
i
4
r
4
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 43 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
Thank you, thank you, thank you!
wrote...

Yesterday
Thanks
wrote...

2 hours ago
Brilliant
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  1313 People Browsing
Related Images
  
 841
  
 758
  
 353
Your Opinion
What's your favorite math subject?
Votes: 293