Questions from Starting Out With Java


Q: Write statements that create the following arrays: 1. A

Write statements that create the following arrays: 1. A 100-element int array referenced by the variable employeeNumbers. 2. A 25-element double array referenced by the variable payRates. 3. A 14-elem...

See Answer

Q: A program uses a variable named array that references an array of

A program uses a variable named array that references an array of integers. You do not know the number of elements in the array. Write a for loop that stores −1 in each element of the array.

See Answer

Q: A program has the following declaration: double[] values;

A program has the following declaration: double[] values; Write code that asks the user for the size of the array and then creates an array of the specified size, referenced by the values variable.

See Answer

Q: Look at the following statements: int[] a = {

Look at the following statements: int[] a = { 1, 2, 3, 4, 5, 6, 7 }; int[] b = new int[7]; Write code that copies the a array to the b array.

See Answer

Q: Look at the following method header: public static void myMethod

Look at the following method header: public static void myMethod(double[] array) Here is an array declaration: double[] numbers = new double[100]; Write a statement that passes the numbers array to th...

See Answer

Q: Write a method named zero, which accepts an int array as

Write a method named zero, which accepts an int array as an argument and stores the value 0 in each element.

See Answer

Q: 1. Write a statement that declares a String array initialized with

1. Write a statement that declares a String array initialized with the following strings: “Mercuryâ€, “Venusâ€, “Earthâ€, and “Marsâ€. 2. Write a loop that displays the contents of each elemen...

See Answer

Q: Recall that we discussed a Rectangle class in Chapter6 . Write code

Recall that we discussed a Rectangle class in Chapter6 . Write code that declares a Rectangle array with five elements. Instantiate each element with a Rectangle object. Use the Rectangle constructor...

See Answer

Q: A video rental store keeps videos on 50 racks with 10 shelves

A video rental store keeps videos on 50 racks with 10 shelves each. Each shelf holds 25 videos. Declare a three-dimensional array large enough to represent the store’s storage system.

See Answer

Q: Write a while loop that lets the user enter a number.

Write a while loop that lets the user enter a number. The number should be multiplied by 10, and the result stored in the variable product. The loop should iterate as long as product contains a value...

See Answer