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
Correct Answer:
Verified
Q23: Class members consist of all of the
Q24: The abstract data type specifies the logical
Q25: Q26: In Java, the reference this is used Q27: Constructors have the same name as the Q29: A mutator method of a class changes Q30: Which of the following class definitions is Q31: In _ copying, each reference variable refers Q32: Consider the following statements. public class Circle Q33: Consider the following class definition. public class
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