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
Correct Answer:
Verified
Q18: A method's parameter can be polymorphic, giving
Q19: Java allows one to create polymorphic references
Q20: An class reference can refer to any
Q21: Can a program exhibit polymorphism if it
Q22: Which of the following methods will sort
Q24: Demonstrate how the following array is sorted
Q25: What kind of performance can you expect
Q26: Polymorphism is achieved by
A) overloading
B) overriding
C) embedding
D)
Q27: Explain how to alter the selection sort
Q28: What are the main programming mechanisms that
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