Question
what is the expected output from this code: public class CircleDemo { public static void main ( String [ ] args ) { Circle circle
what is the expected output from this code:
public class CircleDemo {
public static void main ( String [ ] args ) {
Circle circle = new Circle ( 24.5 ) ;
getObject( circle ) ;
}
public static void getObject ( Circle c ) {
System.out.println( "The radius of circle: " + c.radius ) ;
System.out.println( "The area of circle: " + c.getArea( ) ) ;
}
}
public class Circle {
private double radius ;
public Circle ( double r ) { radius = r ; }
public void setRadius ( String r ) { radius = Double.parseDouble ( r ) ; }
public double getRadius ( ) { return radius ; }
public double getArea ( ) { return 3.14 * radius * radius ; }
}
Java language
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started