× Didn't find what you were looking for? Ask a question
Top Posters
Since Sunday
4
n
3
j
3
o
2
x
2
c
2
2
p
2
n
2
3
2
C
2
z
2
New Topic  
Stromile Stromile
wrote...
Posts: 299
Rep: 0 0
6 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 44 times
1 Reply
Replies
Answer verified by a subject expert
StingerStinger
wrote...
Posts: 310
Rep: 4 0
6 years ago
Sign in or Sign up in seconds to unlock everything for free
1

Related Topics

Stromile Author
wrote...

6 years ago
Helped a lot
wrote...

Yesterday
Just got PERFECT on my quiz
wrote...

2 hours ago
Correct Slight Smile TY
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  939 People Browsing
Related Images
  
 841
  
 1813
  
 3005
Your Opinion
Do you believe in global warming?
Votes: 370

Previous poll results: Who's your favorite biologist?