Questions from Starting Out With Java


Q: What value in an array does the selection sort algorithm look for

What value in an array does the selection sort algorithm look for first? When the selection sort finds this value, what does it do with it?

See Answer

Q: How many times will the selection sort swap the smallest value in

How many times will the selection sort swap the smallest value in an array with another value?

See Answer

Q: What’s wrong with the following array declarations? int

What’s wrong with the following array declarations? int[ ] readings = new int[−1]; double[ ] measurements = new double[4.5];

See Answer

Q: Describe the difference between the sequential search and the binary search.

Describe the difference between the sequential search and the binary search.

See Answer

Q: On average, with an array of 20,000 elements,

On average, with an array of 20,000 elements, how many comparisons will the sequential search perform?

See Answer

Q: If a sequential search is performed on an array, and it

If a sequential search is performed on an array, and it is known that some items are searched for more frequently than others, how can the contents of the array be reordered to improve the average per...

See Answer

Q: What import statement must you include in your code in order to

What import statement must you include in your code in order to use the ArrayList class?

See Answer

Q: Write a statement that creates an ArrayList object and assigns its address

Write a statement that creates an ArrayList object and assigns its address to a variable named frogs.

See Answer

Q: Write a statement that creates an ArrayList object and assigns its address

Write a statement that creates an ArrayList object and assigns its address to a variable named lizards. The ArrayList should be able to store String objects only.

See Answer

Q: How do you add items to an ArrayList object?

How do you add items to an ArrayList object?

See Answer