Suppose you create a class Cylinder to be a subclass of Circle. Analyze the following code: class Cylinder extends Circle { double length; Cylinder(double radius) { Circle(radius); } }

Suppose you create a class Cylinder to be a subclass of Circle. Analyze the following code:


class Cylinder extends Circle {
  double length;
 
  Cylinder(double radius) {
     Circle(radius);
  }
}


A. The program compiles fine, but you cannot create an instance of Cylinder because the constructor does not specify the length of the cylinder.
B. The program has a compile error because you attempted to invoke the Circle class's constructor illegally.
C. The program compiles fine, but it has a runtime error because of invoking the Circle class's constructor illegally.

The correct answer is B


Java

Learn More Multiple Choice Question :