Select the correct answerWhat will be the output of the following Java program?class box { int height; int radius; double pie; double volume; void volume(int height, int radius, double pie) { volume = pie*(radius*radius)*height/3; } } class Prameterized_method { public static void main(String args[]) { box obj = new box(); obj.height = 52; obj.radius = 46; obj.pie = 3.14285714286; obj.volume(45,89,90); System.out.println(obj.volume); } }Options1.069335E70.178501A80.178409D21.069788F6
Question
Select the correct answerWhat will be the output of the following Java program?class box { int height; int radius; double pie; double volume; void volume(int height, int radius, double pie) { volume = pie*(radius*radius)*height/3; } } class Prameterized_method { public static void main(String args[]) { box obj = new box(); obj.height = 52; obj.radius = 46; obj.pie = 3.14285714286; obj.volume(45,89,90); System.out.println(obj.volume); } }Options1.069335E70.178501A80.178409D21.069788F6
Solution
The correct answer is 1.069335E7.
Here's the step-by-step explanation:
The volume method in the box class calculates the volume of a cone using the formula pie*(radius*radius)*height/3.
In the main method, an object obj of the box class is created. The height, radius, and pie values are set to 52, 46, and 3.14285714286 respectively.
However, these values are not used in the calculation because the volume method is called with the parameters 45, 89, and 90.
So, the calculation becomes 90*(89*89)*45/3, which equals 1.069335E7.
Therefore, when obj.volume is printed, the output is 1.069335E7.
Similar Questions
Select the correct answerWhat will be the output of the following Java code? class Area { public static void main(String args[]) { double radii, pi, area; radii = 6.6; pi = 3.14; area = pi * radii * radii; System.out.println(area); } }Options136136.7784136.77136.7760000
elect the correct answerWhat will be the output of the following Java program? class surface_area { int base; int length; int height; double volume; surface_area() { base=12; length=7; } void volume() { volume = 0.5*base*height*length; } } class cons_method { public static void main(String args[]) { surface_area obj = new surface_area(); obj.volume(); System.out.println(obj.volume); } }Options841.00.0error
Select the correct answerWhat will be the output of the following Java program? class shape { int breadth; int height; int area; void area() { area = 1/2 * breadth * height; } void area(int x) { area = x; } } class triangle { public static void main(String args[]) { shape obj = new shape(); obj.breadth = 4; obj.height = 4; obj.area(4); System.out.println(obj.area); } }Options04816
What will be the output of the following code?public class Circle { private double radius; public Circle(double radius) { this.radius = radius; } public double getArea() { return Math.PI * radius * radius; } public static void main(String[] args) { Circle c = new Circle(2.5); System.out.println(c.getArea()); }}Question 14Answera.3.14b.6.28c.19.63d.Compilation error
Analyze the following code: public class Test { public static void main(String[] args) { double radius; final double PI = 3.15169; double area = radius * radius * PI; System.out.println("Area is " + area); } } Group of answer choicesThe program has compile errors because the variable radius is not initialized.The program has a compile error because a constant PI is defined inside a method.The program has no compile errors but will get a runtime error because the radius is not initialized.The program compiles and runs fine.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.