Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Figure 2 shows the class sphere whereas Figure 3 shows the test driver code for the class sphere. public class sphere { String color;

image text in transcribed

3. Figure 2 shows the class sphere whereas Figure 3 shows the test driver code for the class sphere. public class sphere \{ String color; double radius; boolean filled; public sphere(String color, double radius, boolean filled) \{ this.color = color; this.radius = radius; this. filled = filled; \} public double getArea()\{ return Math.PI*radius*radius*4; \}; public double getVolume()\{ return (4.0/3.0)*Math.PI*radius*radius*radius; \} \} Figure 2 public class test \{ public static void main(String args[]) \{ sphere s1= new sphere("red", 4 , true); System.out.println(s1.color); System.out.println(s1.radius); System.out.printin(s1.filled); System.out.printin(s1.getArea()); System.out.println(s1.getVolume()); \} \} Figure 3 3 a. Explain the encapsulation concept in OOP. b. Convert the code in Figures 2 and 3 to implement the encapsulation concept

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

To what extent is news constructed or created?

Answered: 1 week ago