Services
Discover
Homeschooling
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
Java Software Solutions
Quiz 8: Arrays
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 41
Essay
Demonstrate how the following array is sorted using Insertion Sort. Show the array after each pass of the outer loop. [16, 3, 12, 13, 8, 1, 18, 9]
Question 42
Essay
The class Name consists of 4 instance data, String title, String first, String middle, String last. The class has a constructor that is passed all 4 String values and initializes the class appropriately, and has 4 methods, each returns one of the four instance data, called returnTitle( ), returnFirst( ), returnMiddle( ) and returnLast( ). Name[ ] addressBook = new Name[100]; is performed. Write a method that is passed 4 String parameters corresponding to a Name's title, first, middle, and last, and finds this Name in addressBook and returns the index of where this Name was found, or -1 if the Name was not found. Assume that addressBook stores n entries (n is an int).
Question 43
True/False
An array, when instantiated, is fixed in size, but an ArrayList can dynamically change in size when new elements are added to it.
Question 44
True/False
If the following statement is performed: CD[ ] mycollection = new CD[200]; where CD is a previously defined class, then mycollection[5] is a CD object.
Question 45
Essay
Write code fragment to swap the two Strings stored by variables a and b.
Question 46
True/False
Although methods may be declared with a variable length parameter list, class constructors cannot.
Question 47
Essay
The length operator can be used to control a for-loop that iterates through each element of an array, as in for (int j=0; j<list.length; j++) However, this is not necessarily safe. Why not?
Question 48
Essay
Write a method to compute the average of an int array and return the value as a double. The int array and the number of elements in the array are both passed as parameters to the method in that order.
Question 49
True/False
In a two-dimensional array, both dimensions must have the same number of elements, as in[10][10].
Question 50
True/False
A ragged array is a multidimensional array whose initial indices don't all start at zero.
Question 51
True/False
It is possible to sort an array of int, float, double or String, but not an array of an Object class such as a CD class.
Question 52
Essay
Write a code fragment to create a two-dimensional 10x10 array and initialize every element to be the value of i * j where i and j are the two indices (for instance, element [5][3] is 5 * 3 = 15).
Question 53
True/False
To swap the 3ʳᵈ and 4ᵗʰ elements in the int array values, you would do: values[3] = values[4]; values[4] = values[3];
Question 54
Essay
Demonstrate how the following array is sorted using Selection Sort. Show the array after each pass of the outer loop. [16, 3, 12, 13, 8, 1, 18, 9]
Question 55
True/False
Mouse Events deal with detecting the actions of the buttons on a mouse, among other things, while Mouse Motion Events deal with the movement of the mouse with/without buttons being depressed.
Question 56
Essay
Write a method to compute and return the value of max - min where max is the largest element of an int array and min is the smallest element of an int array. The method is passed the int array and an int value that denotes the number of elements in the array. You may assume that the int array has at least 1 element in it.
Question 57
True/False
So long as one is only accessing the elements of an ArrayList, its efficiency is about the same as that of an array. It's only when one begins to insert or remove elements towards the front portion of an ArrayList that its efficiency deteriorates.