What is wrong with the following code? // voluminous.java: interface voluminous { public double volume (); } // Box.java: class Box implements Voluminous { double length, width, height; public...


If the problem with Voluminous and Box in the question above is fixed (if necessary), and Box still implements Voluminous, which of the following lines of code would compile and run correctly?


What is wrong with the following code?<br>// voluminous.java:<br>interface voluminous<br>{<br>public double volume ();<br>}<br>// Box.java:<br>class Box implements Voluminous<br>{<br>double length, width, height;<br>public Box(double 1, double w, double h)<br>{<br>length =<br>width = w;<br>height = h;<br>}<br>1;<br>public double getvolume ()<br>{<br>return (length * width * height);<br>}<br>}<br>O Nothing is wrong. The code will compile and work correctly.<br>O The getvolume method needs to have length. width, and height as parameters.<br>O The Box class doesn't have a method called volume so it doesn't correctly implement voluminous<br>O The variables (length . width. and height need an access level (e.g. public or private )<br>O The Box class must be defined as abstract , because only an abstract class can implement an interface.<br>

Extracted text: What is wrong with the following code? // voluminous.java: interface voluminous { public double volume (); } // Box.java: class Box implements Voluminous { double length, width, height; public Box(double 1, double w, double h) { length = width = w; height = h; } 1; public double getvolume () { return (length * width * height); } } O Nothing is wrong. The code will compile and work correctly. O The getvolume method needs to have length. width, and height as parameters. O The Box class doesn't have a method called volume so it doesn't correctly implement voluminous O The variables (length . width. and height need an access level (e.g. public or private ) O The Box class must be defined as abstract , because only an abstract class can implement an interface.
If the problem with voluminous and Box in the question above is fixed (if necessary), and Box still<br>implements voluminous , which of the following lines of code would compile and run correctly?<br>You can select as many answers as you want.<br>Box x = new Box(2, 3, 4);<br>Voluminous x = new Box(2, 3, 4);<br>Voluminous x = new Voluminous (2, 3, 4);<br>voluminous [] a = new Voluminous[18];<br>a[e] = new Box(2, 3, 4);<br>voluminous x - new Voluminous ();<br>Box x = new Box ();<br>

Extracted text: If the problem with voluminous and Box in the question above is fixed (if necessary), and Box still implements voluminous , which of the following lines of code would compile and run correctly? You can select as many answers as you want. Box x = new Box(2, 3, 4); Voluminous x = new Box(2, 3, 4); Voluminous x = new Voluminous (2, 3, 4); voluminous [] a = new Voluminous[18]; a[e] = new Box(2, 3, 4); voluminous x - new Voluminous (); Box x = new Box ();

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here