Java Final

¡Supera tus tareas y exámenes ahora con Quizwiz!

A search algorithm is: A) Method for locating a specific item in a larger collection of data B) Is rarely used with arrays C) Arranges elements in ascending order D) Arranges elements in descending order

A

Assuming that inputFile references a Scanner object that was used to open a file, which of the following statements will read an int from the file? A) int number = inputFile.nextInt(); B) int number = inputFile.next(); C) int number = inputFile.readInt(); D) int number = inputFile.integer();

A

When you pass the name of a file to the PrintWriter constructor and the file already exists, A) it will be erased and a new empty file with the same name will be created. B) an IOException will be thrown. C) a new empty file will be created with the same name and a different version number. D) the file will be opened and new data will be appended to its current contents.

A

Which of the following will open a file named MyFile.txt and allow you to read data from it? A) File file = new File("MyFile.txt"); B) Scanner inputFile = new Scanner("MyFile.txt"); C) File file = new File("MyFile.txt"); Scanner inputFile = new Scanner(file); D) PrintWriter inputFile = new PrintWriter("MyFile.txt");

A

Values that are sent into a method are called ________.

Arguments

The following statement creates an ArrayList object. What is the purpose of the <String> notation? ArrayList<String> arr = new ArrayList<String>();

ArrayList<String> arr = new ArrayList<String>();

A sentinel value _________ and signals that there are no more values to be entered. A) is a different data type than the values being processed B) is a special value that cannot be mistaken as a member of the list C) indicates the start of a list D) guards the list

B

Event listeners must: A) Not receive any argument B) Implement an interface C) Exit the application once it handled the event D) Be included in private inner classes

B

If the main method calls method A, and method A calls method B, what happens when method B finishes? A) control is returned to the main method B) control is returned to method A C) an IOException is thrown D) the program terminates

B

A ragged array is: A: A two-dimensional array for which the number of rows is unknown B: A one-dimensional array for which the number of elements is unknown C: A two-dimensional array where the rows are of different lengths D: There is no such thing as a ragged array

C

If numbers is a two-dimensional int array that has been initialized and total is an int that has been set to 0, which of the following will sum all the elements in the array?

for (int row = 0; row < numbers.length; row++) { for (int col = 0; col < numbers[row].length; col++) total += numbers[row][col]; }

Assume that inputFile references a Scanner object that was used to open a file. Which of the following while loops shows the correct way to read data from the file until the end of the file is reached? A) while (inputFile != null) { ... } B) while (!inputFile.EOF) { ... } C) while (inputFile.hasNext()) { ... } D) while (inputFile.nextLine == " ") { ... }

C

If str1 and str2 are both Strings, which of the following will correctly test to determine whether str1 is less than str2? A) str1 < str2 B) str1.equals(str2) < 0 C) str1.compareTo(str2) < 0 D) str1.lessThan(str2) == true

C

f method A calls method B, and method B calls method C, and method C calls method D, when method D finishes, what happens? Control is returned to method __.

C

If you attempt to use a local variable before it has been given a value: a _____ ______ will occur.

Compiler error

A for loop normally performs which of these steps? A) initializes a control variable to a starting value B) tests the control variable by comparing it to a maximum/minimum value and terminate when the variable reaches that value C) updates the control variable during each iteration D) all of the above

D

Assume that radio references a JRadioButton. To click the radio button in code use the following statement: A) Click (radio, true); B) radio.Click(); C) Click(radio); D) radio.doClick();

D

Given the following statement, which statement will write "Calvin" to the file DiskFile.txt? PrintWriter diskOut = new PrintWriter("DiskFile.txt"); A) System.out.println(diskOut, "Calvin"); B) DiskFile.println("Calvin"); C) PrintWriter.println("Calvin"); D) diskOut.println("Calvin");

D

If chr is a character variable, which of the following if statements is written correctly? A) if (chr = "a") B) if (chr == "a") C) if (chr = 'a') D) if (chr == 'a')

D

If numbers is a two-dimensional array, which of the following would give the length of row r? A) numbers.length B) numbers.length[r] C) numbers[r].length[r] D) numbers[r].length

D

A GUI program automatically stops executing when the end of the main method is reached. T or F

False

A sorting algorithm is used to locate a specific item in a larger collection of data. T or F

False

All operating systems offer the same set of GUI components

False

Data stored in an object are called _____.

Fields

This type of loop is ideal in situations where the exact number of iterations is known: _______ loop

For

In GUI terminology, a container that can be displayed as a window is a:

Frame

When a parameter value is changed within the body of a method: the change has (NO EFFECT or AN EFFECT) _______ on the associated argument value when the method returns.

No effect

A special variable that holds a value being passed into a method is called what?

Parameter

This type of operator determines whether a specific relationship exists between two values:

Relational

Multiple alternative decision structure is a ______ statement.

Switch

Assume that the variable checkbox references a JCheckBox object. To determine whether the check box has been selected, use the following code:

if (checkBox.isSelected()) {/code to execute, if selected/}

kb.nextInt(); is an example of a __________ method.

value returning

This type of method performs a task and then terminates: _____

void

A file must always be opened before using it and closed when the program is finished using it. T or F

True

An ArrayList object automatically expands in size to accommodate the items stored in it. T or F

True

Check boxes may be grouped in a ButtonGroup, like radio buttons are

True

Java does not limit the number of dimensions that an array may have. T or F

True

Objects in an array are accessed with subscripts, just like any other data type in an array. T or F

True

Some of the common GUI components are buttons, labels, texts fields, check boxes, and radio buttons

True

When an array of objects is declared, but not initialized, the array values are set to null. T or F

True

When the continue statement is encountered in a loop it causes a loop to stop its current iteration and begin the next one. T or F

True

When you open a file with the PrintWriter class, the class can potentially throw an IOException. T or F

True

You can use the PrintWriter class to open a file for writing and write data to it.

True

he ActionEvent argument that is passed to an action listener's actionPerformed method is the event object that was generated in response to an event. T or F

True

In order to execute a _____ must be called by another _____

method, method


Conjuntos de estudio relacionados

Human Nutrition Final Study Tool

View Set

AP World History Self-Quiz Ch 33 19th Century Asia

View Set

PN Pharmacology Online Practice 2020A

View Set