Filters
Question type

Study Flashcards

Although methods may be declared with a variable length parameter list, class constructors cannot.

A) True
B) False

Correct Answer

verifed

verified

An int array stores the following values. Use the array to answer the questions below. An int array stores the following values. Use the array to answer the questions below.    -How many passes will it take in all for Selection Sort to sort this array? A)  2 B)  4 C)  5 D)  6 E)  7 -How many passes will it take in all for Selection Sort to sort this array?


A) 2
B) 4
C) 5
D) 6
E) 7

F) C) and D)
G) A) and C)

Correct Answer

verifed

verified

If x is a char, and values is an int array, then values[x]


A) causes a syntax error
B) causes an Exception to be thrown
C) casts x as an int based on x's position in the alphabet (for instance, if x is 'a' then it uses 0 and if x is 'z' then it uses 25)
D) casts x as an int based on x's ASCII value (for instance, if x is 'a' then it uses 97 and if x is 'z' then it uses 122)
E) casts x as an int based on the digit that is stored in x (for instance, if x is '3' it uses 3) but throws an exception if x does not store a digit

F) A) and C)
G) None of the above

Correct Answer

verifed

verified

For the questions below, assume values is an int array that is currently filled to capacity, with the following values: For the questions below, assume values is an int array that is currently filled to capacity, with the following values:    -The statement System.out.println(values[7]) ; will A)  output 7 B)  output 18 C)  output nothing D)  cause an ArrayOutOfBoundsException to be thrown E)  cause a syntax error -The statement System.out.println(values[7]) ; will


A) output 7
B) output 18
C) output nothing
D) cause an ArrayOutOfBoundsException to be thrown
E) cause a syntax error

F) B) and C)
G) None of the above

Correct Answer

verifed

verified

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]

Correct Answer

verifed

verified

16, 3, 12, 13, 8, 1, 18, 9 (initial)
3, ...

View Answer

An int array stores the following values. Use the array to answer the questions below. An int array stores the following values. Use the array to answer the questions below.    -Which of the following lists of numbers would accurately show the array after the first pass through the Selection Sort algorithm? A)  9, 4, 12, 2, 6, 8, 18 B)  4, 9, 12, 2, 6, 8, 18 C)  2, 4, 12, 9, 6, 8, 18 D)  2, 4, 6, 8, 9, 12, 18 E)  2, 4, 9, 12, 6, 8, 18 -Which of the following lists of numbers would accurately show the array after the first pass through the Selection Sort algorithm?


A) 9, 4, 12, 2, 6, 8, 18
B) 4, 9, 12, 2, 6, 8, 18
C) 2, 4, 12, 9, 6, 8, 18
D) 2, 4, 6, 8, 9, 12, 18
E) 2, 4, 9, 12, 6, 8, 18

F) B) and E)
G) C) and D)

Correct Answer

verifed

verified

The Key Events include


A) keyPressed, keyReleased
B) keyPressed, keyReleased, keyTyped
C) keyPressed, keyReleased, keyTyped, keyDown, keyUp
D) keyDown, keyUp, keyTyped
E) none of the above

F) B) and D)
G) A) and E)

Correct Answer

verifed

verified

Say that you want to construct a tiny drawing program, where the objects are defined using line segments. One might use the rubber-banding ideas presented in this chapter to define the endpoints of line segments, hooking them together into a polyline. One might provide a button that turns a polyline into a polygon. If this approach is taken, what would be a good way to represent the data involved in this program: the points, the line segments, the polylines, the polygons?

Correct Answer

verifed

verified

One good way to store the required data ...

View Answer

Assume that BankAccount is a predefined class and that the declaration BankAccount[ ] firstEmpireBank; has already been performed. Then the following instruction reserves memory space for firstEmpireBank = new BankAccount[1000];


A) a reference variable to the memory that stores all 1000 BankAccount entries
B) 1000 reference variables, each of which point to a single BankAccount entry
C) a single BankAccount entry
D) 1000 BankAccount entries
E) 1000 reference variables and 1000 BankAccount entries

F) All of the above
G) B) and C)

Correct Answer

verifed

verified

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).

Correct Answer

verifed

verified

public int findName(String title, String first, String middle, String last) { for (int j=0; j<n; j++) if (title.equals(addressBook[j].getTitle( ) && first.equals(addressBook[j].getFirst( ) && middle.equals(addressBook[j].getMiddle( ) && last.equals(addressBook[j].getLast( )) return j; return -1; }

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.

A) True
B) False

Correct Answer

verifed

verified

A Polygon object in Java is


A) a shape defined as a collection of x, y points
B) a shape defined as a collection of lines
C) a shape defined as a collection of polylines
D) an array of shapes
E) 2 lines connected by 1 common point

F) All of the above
G) A) and E)

Correct Answer

verifed

verified

Arrays have a built in toString method that returns all of the elements in the array as one String with "\n" inserted between each element.

A) True
B) False

Correct Answer

verifed

verified

Write code to create a JPanel with 4 JCheckBox GUI components and two JLabels for output, one that says "Current cost is" and the other that outputs the computed cost based on which of the food items has been selected.

Correct Answer

verifed

verified

FoodListener fl = new FoodListener( );
J...

View Answer

Given the following declarations, which of the following variables are arrays? Int[ ] a, b; Int c, d[ ];


A) a
B) a and b
C) a and d
D) a, b and d
E) a, b, c and d

F) A) and D)
G) A) and C)

Correct Answer

verifed

verified

D

In Java, an array can only store one type of data. For instance, you cannot create an array that stores both double and String values.

A) True
B) False

Correct Answer

verifed

verified

True

As described in the Software Failure, a race condition bug in a computer program is one in which


A) a race is held to see which team can finish a computer program first
B) two or more processes that start at the same time finish at different times
C) two or more processes race to create an error
D) two or more processes that share the same data continue running under wrong assumptions after one of the processes changes the data
E) none of the above

F) B) and D)
G) C) and D)

Correct Answer

verifed

verified

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.

A) True
B) False

Correct Answer

verifed

verified

For the questions below, assume values is an int array that is currently filled to capacity, with the following values: For the questions below, assume values is an int array that is currently filled to capacity, with the following values:    -Which of the following loops would adequately add 1 to each element stored in values? A)  for (j=1; j<values.length; j++)  values[j]++; B)  for (j=0; j<values.length; j++)  values[j]++; C)  for (j=0; j<=values.length; j++)  values[j]++; D)  for (j=0; j<values.length-1; j++)  values[j]++; E)  for (j=1; j<values.length-1; j++)  values[j]++; -Which of the following loops would adequately add 1 to each element stored in values?


A) for (j=1; j<values.length; j++) values[j]++;
B) for (j=0; j<values.length; j++) values[j]++;
C) for (j=0; j<=values.length; j++) values[j]++;
D) for (j=0; j<values.length-1; j++) values[j]++;
E) for (j=1; j<values.length-1; j++) values[j]++;

F) A) and C)
G) A) and B)

Correct Answer

verifed

verified

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]

Correct Answer

verifed

verified

16, 3, 12, 13, 8, 1, 18, 9 (initial)
1, ...

View Answer

Showing 1 - 20 of 70

Related Exams

Show Answer