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
Q28: Class members consist of all of the
Q29: A mutator method of a class changes
Q30: MysteryClass
-first: int
-second: double;
+MysteryClass()
+MysteryClass(int)
+MysteryClass(double);
+MysteryClass(int, double)
+setData(int, double): void
+getFirst(): int
+getSecond():
Q31: MysteryClass
-first: int
-second: double;
+MysteryClass()
+MysteryClass(int)
+MysteryClass(double);
+MysteryClass(int, double)
+setData(int, double): void
+getFirst(): int
+getSecond():
Q34: Consider the following statements.public class Circle
{
Private double
Q35: Consider the following class definition.public class Rectangle
{
Private
Q36: Which of the following class definitions is
Q37: MysteryClass
-first: int
-second: double;
+MysteryClass()
+MysteryClass(int)
+MysteryClass(double);
+MysteryClass(int, double)
+setData(int, double): void
+getFirst(): int
+getSecond():
Q38: Every object has access to a reference
Q40: Classes that are defined within other classes
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