For the questions below: Assume this Box class: public class Box { double length
ID: 3685109 • Letter: F
Question
For the questions below: Assume this Box class:
public class Box
{
double length;
double width;
double height;
Box(double l, double w, double h)
{
length = l;
width = w;
height = h;
}
double volume( )
{
return length * width * height;
}
}
How you can find the max number from values list? Give the main code.
Array
To initialize a String array names to store the three Strings "Huey", "Duey" and "Louie", you would do
A) String names = {"Huey", "Duey", "Louie"};
B) String[ ] names = {"Huey", "Duey", "Louie"};
C) String[ ] names = new String{"Huey", "Duey", "Louie"};
D) String names[3] = {"Huey", "Duey", "Louie"};
E) String names; names[0] = "Huey"; names[1] = "Duey"; names[2] = "Louie";
Describe what problem occurs in the following code. What modifications should be made to it to eliminate the problem?
int[] numbers = {3, 2, 3, 6, 9, 10, 12, 32, 3, 12, 6};
for (int count = 1; count <= numbers.length; count++)
System.out.println(numbers[count]);
Write an array declaration and any necessary supporting classes to represent Students’ names for a class of 25 students
Write code that prints the values stored in an array called names backwards.
For the questions below, assume values is an int array that is currently filled to capacity, with the following values:
9, 4, 12, 2, 6, 8, 18
Which of the following loops would adequately add 1 to each element stored in values?
A) for (index=1; index<values.length; index++) values[index]++;
B) for (index=0; index<values.length; index++) values[index]++;
C) for (index=0; index<=values.length; index++) values[index]++;
D) for (index=0; index<values.length-1; index++) values[index]++;
E) for (index=1; index<values.length-1; index++) values[index]++;
Explanation / Answer
Code that prints the values stored in an array: import java.util.Scanner; public class ArrayHandout { public static void main(String[] args) { Scanner input = new Scanner(System.in); int[] numbers = new int[10]; System.out.print("Please enter " + numbers.length + " values:"); for(int index = 0; indexRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.