AP JAVA 10
The____ operator means not equal to.
!=
The decrement operator is
--
Alex is creating loops that iterate through an array of 500 integers called abc. Alex is trying to find the first location of a value in the array. The variable loc initially equals _______.
-1
Gabrielle is writing a program that finds the average of a list of positive numbers. Gabrielle uses ____ as the sentinel.
-1
When referring to an array element, the method selector is ______.
.
The _______ symbol on a button in a GUI interface moves to the first record in the database and displays its data.
<<
The _______ symbol on a button in a GUI interface moves to the last record in the database and displays its data.
>>
Procedural decomposition
A design strategy whereby complex tasks are split into simpler subtasks that are implemented with methods or procedures.
Structure chart
A graphical method of indicating the relationship between modules when designing the solution to a problem.
Initializer list
A means of expressing a set of data that can be assigned to the cells of an array in one statement.
Enhanced for loop
A special type of for loop that traverses an array or array list from beginning to end, binding a local variable to each element in the array or list.
A method in the Math class.
Abs
____________________ statements execute within each pass and implement the calculation in question.
Body
Alex is creating loops that iterate through an array of 500 integers called abc. Alex uses a(n) _______ variable to break out of a loop once the presence of a particular number is found in an array.
Boolean
An off-by-one error occurs when the value returned is one more or less than the expected result.
F
In a for statement, the counter is updated at the top of the loop.
F
It is better to underuse braces or parentheses than to overuse them.
F
Use an if statement to instruct a program to execute one statement if the condition is true, and another if the condition is false.
F
n Java, while and if-else are examples of conditional statements.
F, control
When a program responds more slowly than expected, it is reasonable to assume that it is stuck in an overloading loop.
F, infinite
A program that controls how many times a loop is executed is called a task-controlled loop.
F. count
Gabrielle is using a text file to input the list of numbers. Which of the following is NOT true? a. If the file is missing, the JVM will thrown an I/O exception. b. The numbers must be separated by whitespace characters. c. Gabrielle uses the PrintWriter class to read the data in the text file. d. The text file must contain a special character that marks the end of the file.
Gabrielle uses the PrintWriter class to read the data in the text file.
Describe each of the four components of a loop. Why is it important to be familiar with these components? What kinds of errors can be introduced for each?
It is important to be familiar with the components and how a logic error could be introduced in each component. In order to debug logic errors in a program, you must know what the components' purposes are. The four typical components are: 1. Initializing statements. These statements initialize variables used within the loop. Can result in an initialization error if the variable is not initialized. 2. Terminating condition. This condition is tested before each pass through the loop to determine if another iteration is needed. Off-by-one and infinite loop errors can result, where the program does not terminate where expected (or at all). 3. Body statements. These statements execute with each iteration and implement the calculation in question. Errors in the loop body can be difficult to detect, and can include misuse of operators. 4. Update statements. These statements, which usually are executed at the bottom of the loop, change the values of the variables tested in the terminating condition. If the update statement is in the wrong place, the calculations can be off.
___ is when the same name is used for two different methods.
Overloading
Carter thinks his program is stuck in an infinite loop. What should he do to his PC to make it stop?
Press Ctrl+C.
Data can be output to a text file using the class ____.
PrintWriter
A program can output data to a file.
T
A program used to simulate coin toss results uses a random number generator.
T
An if-else statement is commonly used to check user inputs for validity before processing them.
T
Figure 4-1 above is an example of a flowchart.
T
For a loop to terminate, each pass must move the variables in the condition significantly closer to satisfying the condition.
T
In a while statement, if the condition is false from the outset, the statement(s) inside the loop never execute.
T
Some programmers prefer to use for loops instead of while loops because the loop control variable can be declared in its header.
T
m++ and m = m + 1 are the same thing.
T
In figure 10-2 above, all of the following are true EXCEPT _______.
The actual and formal parameters do not refer to the same object.
Logical size
The number of data items actually available in a data structure at a given time.
What is the difference between physical size and logical size?
The physical size is the amount of all the cells available in an array, but the logical size is how many are used.
Range-bound error
The situation that occurs when an attempt is made to use an array index value that is less than 0 or greater than or equal to the size of the array.
When referring to an array element, the subscript selector is ______.
[ ]
Array
a data structure whose elements are accessed by means of index positions
What is an array?
a data structure whose elements are accessed by means of index positions
Subscript
a string that represents a segment of another string
Element
a value that is stored in an array
Which of the following is true about using a text file for input?
a. The data set can be much larger. b. Data can be input faster and with less chance of error. c. Data can be used repeatedly with the same program or with different programs. d. All of the above are true.
Use an if statement to instruct a program to execute one statement if the condition is true
and another if the condition is false.,F
A(n) ____ is a small window that asks for information
and includes a text field and command buttons.,input dialog box
How do you access the instance variable length in an array?
arrayName.length
How are the elements in an array indexed and addressed?
arrayName[index]
Parallel arrays
arrays of the same length but with different component types
What are parallel arrays?
arrays of the same length but with different component types
Because it returns a value of true or false, the condition in an if statement must be a(n) ____ expression.
boolean
An item's position within an array is called its ______.
both (index) and (subscript) are true
____ must always occur in pairs
braces
Exits a loop before the condition is false.
break
To get out of a loop prematurely, use a(n) ____ statement.
break
An I/O exception is in the category of ____ exceptions.
checked
The ____________________ operator decreases a variable's value by one.
decrement
For a loop to terminate
each pass must move the variables in the condition significantly closer to satisfying the condition.,T
The basic syntax for referring to an array _______ has the form <array name>[<index>].
element
The items in an array are called ______.
elements
A(n) _______ loop visits each element in an array from the first position to the last position.
enhanced for
In a(n) ____-controlled loop, the continuation condition is tested at the top of the loop on each pass.
entry
What happens when a program encounters an operation that it cannot perform at runtime.
exception
The ____ statement is used to write count-controlled loops.
for
How can you use a standard for loop to step through all the elements in an array?
for(int i = 0; i < abc.length; i++)
The Boolean variable ______ is used to break out of a loop if a particular number in an array.
found
What are the default values in an array?
garbage
In a while statement
if the condition is false from the outset, the statement(s) inside the loop never execute.,T
Use a(n) ____ statement rather than two if statements when the alternative courses of action are mutually exclusive.
if-else
A typical loop has four component parts
including all of the following EXCEPT ___ statements.,verification
The ____________________ operator increases a variable's value by one.
increment
A(n) ____ is a small window that asks for information, and includes a text field and command buttons.
input dialog box
How do you array, abc, of 500 intergers of type int?
int[] abc = new int[500];
How do you declare a 1 dimensional array, abc, of type int?
int[] abc;
How do you use an initializer list?
int[] abc={1,2,3,4,5};
When a program responds more slowly than expected
it is reasonable to assume that it is stuck in an overloading loop.,F, infinite
Each pass through a loop is called a(n) ____________________.
iteration
To access the _______ cell in an array, use the expression <array>.length - 1
last
In a GUI, you should define a separate ______ class for each command button.
listener
An array with 20 ints that receives 5 ints from interactive input has a(n) _______ size of 5.
logical
Ravi is writing a program for a client that uses arrays. Ravi must indicate an array's ______ in the loop when the array is not full.
logical size
Carter has written a program that has some errors that he needs to fix. Carter realizes that the loop in his program goes around once more than necessary
meaning that he has a(n) ____ error.,off-by-one
Organizing code into two classes called the ______ and the view splits the code between managing the interface and manipulating the database.
model
A(n) ____________________ control statement is located inside another control statement.
nested
Can an array's size be changed after it is instantiated?
no
In a text file
numeric data can be separated by any of the following EXCEPT ____.,return
Arrays are ______ and must be instantiated before being used.
objects
Carter has written a program that has some errors that he needs to fix. Carter realizes that the loop in his program goes around once more than necessary, meaning that he has a(n) ____ error.
off-by-one
If you want to keep a list of people's names and ages, you can use two arrays in which corresponding elements are related by using ______ arrays.
parallel
When an object is used as a(n) _______ to a method, what gets passed is a reference to the object and not the object itself.
parameter
An array with 20 ints that receives 5 ints from interactive input has a(n) _______ size of 20.
physical
The simplest way to add a data element to an array is to ________.
place it after the last available item
A class used to simulate stock market fluctuations.
random
In a text file, numeric data can be separated by any of the following EXCEPT ____.
return
A(n) ____ is a special value that marks the end of a list.
sentinel
If a method's signature is labeled ____, the message is sent to the method's class instead of to an object.
static
A loop that continues until something specific is accomplished is called a(n) ____-controlled loop.
task
Gabrielle is using a text file to input the list of numbers. Which of the following is NOT true? a. If the file is missing
the JVM will thrown an I/O exception. b. The numbers must be separated by whitespace characters. c. Gabrielle uses the PrintWriter class to read the data in the text file. d. The text file must contain a special character that marks the end of the file.,Gabrielle uses the PrintWriter class to read the data in the text file.
Because it returns a value of true or false
the condition in an if statement must be a(n) ____ expression.,boolean
In a(n) ____-controlled loop
the continuation condition is tested at the top of the loop on each pass.,entry
In a for statement
the counter is updated at the top of the loop.,F
If a method's signature is labeled ____
the message is sent to the method's class instead of to an object.,static
Physical size
the number of memory units available for storing data in a data structure
Index
the relative position of the components of an array
Figure 10-1 above shows _______.
two variables referring to the same array object
What are ragged arrays?
two-dimensional array in which each row may have a different length.
A statement that changes the values of the variables tested in the termination condition.
update
To get out of a loop prematurely
use a(n) ____ statement.,break
A typical loop has four component parts, including all of the following EXCEPT ___ statements.
verification
Figure 4-2 above represents the behavior of a(n) ____ statement.
while
n Java
while and if-else are examples of conditional statements.,F, control
Ravi is writing a program for a client that uses arrays. Ravi uses _______ to indicate an initializer list.
{ }
The presence or absence of the ____ symbol(s) can seriously affect the logic of a selection statement.
{ }