Menu

[Solved]1 Following Code Radius Private Cirle Class Mycircle Object Circle Class Following Highlig Q37263437

1) In the following code, radius is private in the Circle class, and my Circle is an object of Circle class. Does the following highlighted code cause any problems Explain why.

public class Circle {

private double radius = 1.0;

// find the area of this circle

double getArea (){

return radius * radius * Math.PI;

}

public static void main(String[] a) {

Circle myCircle = new Circle();

System.out.println(“Radius is” + myCircle.radius);

}

}

Expert Answer


Answer to 1) In the following code, radius is private in the Circle class, and myCircle is an object of Circle class. Does the foll… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *