Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the result of this code of the following code, please do ASAP It has been suggested that C++ and JAVA support implementation of

What is the result of this code of the following code, please do ASAP

It has been suggested that C++ and JAVA support implementation of abstract data types but only at the cost of giving up information hiding. Briefly discuss this claim.

Analyze the following code from the viewpoint of information hiding or data encapsulation.

public class CircleWithPrivateDataFields {

/** The radius of the circle */

private double radius = 1;

/** The number of the objects created */

private static int numberOfObjects = 0;

/** Construct a circle with radius 1 */

public CircleWithPrivateDataFields() {

numberOfObjects++;

}

/** Construct a circle with a specified radius */

public CircleWithPrivateDataFields(double newRadius) {

radius = newRadius;

numberOfObjects++;

}

/** Return radius */

public double getRadius() {

return radius;

}

/** Set a new radius */

public void setRadius(double newRadius) {

radius = (newRadius >= 0) ? newRadius : 0;

}

/** Return numberOfObjects */

public static int getNumberOfObjects() {

return numberOfObjects;

}

/** Return the area of this circle */

public double getArea() {

return radius * radius * Math.PI;

}

}

What is the result of this code?

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

Step: 3

blur-text-image

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

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students also viewed these Databases questions

Question

If E (W) = and Var (W) =2, show that r(-) Var(W )- =0 and

Answered: 1 week ago