"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 the above
Correct Answer:
Verified
Q18: A method's parameter can be polymorphic, giving
Q35: Although insertion sort and selection sort have
Q36: Which statement is completely True?
A) Java upcasts
Q37: What is printed?
public class Inherit
{
abstract class
Q38: What is printed?
public class Inherit
{
class Figure
{
void
Q39: What is printed?
public class Inherit
{
class Figure
{
void
Q41: Choosers-like file choosers and color choosers-provide a
Q41: Demonstrate how the following array is sorted
Q42: A class reference can refer to any
Q44: Binary search can be used on unsorted
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents