Asked by
Katryna Smith
on Oct 27, 2024Verified
Consider the following class definition.public class Cylinder
{
Private double baseRadius;
Private double height; public Cylinder ()
{
BaseRadius = 0;
Height = 0;
} public Cylinder (double l, double h)
{
BaseRadius = l;
Height = h;
} public void set(double r, double h)
{
BaseRadius = r;
Height = h;
} public String toString()
{
Return (baseRadius + " " + height) ;
} public double SurfaceArea()
{
Return 2 * 3.14 * baseRadius * height;
} public double volume()
{
Return 3.14 * baseRadius * baseRadius * height;
}
}Suppose that you have the following declaration. Cylinder cyl = new Cylinder(1.5, 10) ;Which of the following sets of statements are valid in Java?
(i)
Cyl.surfaceArea() ;
Cyl.volume() ;
Cyl.print() ;
(ii)
Print(cyl.surfaceArea) ;
Print(cyl.volume() ) ;
A) Only (i)
B) Only (ii)
C) Both (i) and (ii)
D) None of these
BaseRadius
Typically refers to a property or variable used to denote the radius of a base in geometric shapes or structures.
Height
Height refers to the measurement of an object or individual from base to top or from the ground to its highest point.
Cylinder
A geometric solid that is bounded by a circular base, a congruent parallel top, and a curved surface that connects the two circles.
- Develop an understanding of the key principles of object-oriented programming, which involve classes, methods (public and private), constructors, and objects.
Verified Answer
MS
Learning Objectives
- Develop an understanding of the key principles of object-oriented programming, which involve classes, methods (public and private), constructors, and objects.