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.set(2.5, 10); System.out.println(cyl); System.out.println(cyl.volume()); System.out.println(cyl.syfaceArea()); (i) cyl.set(2.5, 10); cyl.print(); cyl.volume.print(); cyl.syrfaceArea.print(); a. Only (i) b. Only (ii) c. Both  d. None of these.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 5PE
icon
Related questions
Question

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.set(2.5, 10);

System.out.println(cyl);

System.out.println(cyl.volume());

System.out.println(cyl.syfaceArea());

(i)

cyl.set(2.5, 10);

cyl.print();

cyl.volume.print();

cyl.syrfaceArea.print();

a. Only (i)

b. Only (ii)

c. Both 

d. None of these. 

 

60. Consider the following class definition.
public class Cylinder
{
private double baseRadius;
private double height;
public Cylinder ()
{
baseRadius = 0;
height = 0;
%3D
public Cylinder (double 1, double h)
{
baseRadius = 1;
height = h;
}
public void set (double r, double h)
{
baseRadius = r;
height = h;
%3D
public String toString ()
{
return (baseRadius + " " + height);
}
TE
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);
Transcribed Image Text:60. Consider the following class definition. public class Cylinder { private double baseRadius; private double height; public Cylinder () { baseRadius = 0; height = 0; %3D public Cylinder (double 1, double h) { baseRadius = 1; height = h; } public void set (double r, double h) { baseRadius = r; height = h; %3D public String toString () { return (baseRadius + " " + height); } TE 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);
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT