stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
Loops, Arrays, and Classes Flashcards | StudBud
Explore
/
Loops, Arrays, and Classes
Loops, Arrays, and Classes
59 terms
·
StudBud Administration
·
1,218 plays
Introduction to Java chapter 7 & 8 review with a few questions from Chapter 6 for reinforcement
Flashcards
59 cards
F
Practice quiz
P
Host live
L
Questions
59
Answers
1
A ______ search inspects elements in sequence until a match is found.
pop
bubble sort
binary
linear
2
You can use the ______ ____ loop to visit all elements of an array.
Nested For
Do While
Enhanced For
Compound Do
3
A loop executes instructions repeatedly while a condition is ___________.
false
random
unknown
true
4
Features of a class that are accessible to all clients (e.g. methods, variables, etc.) make up:
private interface
methods
programs
public interface
5
The JUnit Philosophy is to run all tests whenever ___________________.
you change your code
you feel like it
your organization requires it
your manager requires it
6
When swapping two elements in an array, you need a ________ variable.
instant
paramater
local
temporary
7
Which is considered by the text to be the most important consideration when designing a class?
Should represent multiple concepts only if they're related
Should represent no more than three specific concepts
Should represent single concept/object from problem domain
Should represent an appropriate mathematical concept
8
In a partially filled array, then number of slots in the array that aren't currently used is:
length of array minus number elements in array
number elements in array minus length of array
length of array plus number of elements currently in array
number of elements currently in array
9
What are the three loops in Java?
ElseIf, Do While, When
While, For, Do
Do - For; If - Else; While
Do-While, Do-When, Do-Until
10
If collection size never changes / if concerned about efficiency in sequence of primitive types
use an excel spreadsheet
use another programming language
use an array list
use an array
11
Where in a class should static variables be declared and initialized?
Inside the class, but outside of any method body
Inside the constructor method
Outside the class - in a separate designated static class
Outside the class, but inside the same physical file
12
In Java, you can't directly insert primitive types values in array lists; you must use a ______
reference class
derivative class
replacement class
wrapper class
13
An arrangement consisting of rows and columns of values is called a ______ _______or a matrix.
two-dimensional array
elemental table
spread sheet
columnar table
14
When an array reading and storing input runs out of space:
array could be "grown" using new command & copyOf method
the array could be "grown" using growArray method
program could be recompiled with bigger size for array
it automatically resizes to accommodate new elements
15
What is the valid range of index values for an array of size 10?
0 to 9
0 to 10
1 to 9
1 to 10
16
An array index must be at least ________ and less than the size of the array.
one
zero
can be any number
none of these
17
If your program accesses an array through an out-of-bounds index, what type of error is it?
No error, just doesn't computer properly
Compiler error
Run-time error
No error, just hangs
18
What is the result of the given code snippet?
the elements of the array values are initialized to zero
the elements of the array element are initialized to zero
the array values is not modified
the 1st element of array values is initialized to zero
19
Input __________ is the process of linking a file to the input of a program.
Replacement
Requirement
Requisite
Redirection
20
Which of the following most likely indicates that you've chosen a good name for your class?
Can easily determine by name how many concepts represented
The name consists of a single word
You can tell by the name what an object of class represents
Name describes what task the class will perform
21
Which of the following statements describes the scope of a local variable?
From the beginning through the end of block that encloses it
from declaration to end of the block that encloses it
From point of initialization to end of block enclosing it
From point of its declaration to point where set to null
22
If you don't include a package statement in your class source file, its classes will be placed:
in java.awt
in the default package, which has no name
in java.lang
in java.util
23
Identify the correct statement for defining an integer array named numarray of ten elements:
int[] numarray = new int[9];
int numarray[10];
int[10] numarray;
int[] numarray = new int[10];
24
Individual elements in a two-dimensional array are accessed by using two index values, _______
array[i]{j}
array{i}[j]
array[i][j]
array[i,j]
25
Which is a valid line of code for displaying the twenty-eighth element of
somearray?
System.out.println(somearray(28));
System.out.println(somearray[28]);
System.out.println(somearray(27));
System.out.println(somearray[27]);
26
Use the expression _________ to find the number of elements in an array.
array{length}
length.array
array(length)
array.length
27
Any kind of modification of data that is observable outside the method is considered a _____
side effect
intended consequence
unexplainable
unacceptable
28
When an array
myArray
is only partially filled, how do you keep track of current # of elements?
maintain a variable that stores the current # of elements
access myArray.length()
access myArray.length()-1
access myArray.currentElements()
29
Saving tests that you use to find program bugs and verify that fixes work into a collection is:
test program
test cases
test suite
test group
30
With a partially filled array, you need to keep a companion variable for the current size like:
WhereamI
length
currentSize
Counter
31
A loop that runs forever & can be stopped only by killing the program/restarting the computer:
infinite loop
terminal loop
run-on loop
nested loop
32
double[] values = new double[10] defines an array of 10 elements with an index range from
unknown
whatever numbers you set
0-9
1-10
33
By combining fundamental ________, you can solve complex programming tasks
problems
algorithms
test cases
pseudocode
34
Objects that move around during the lifetime need to store their position in a ___________
constant
method
instance variable
class
35
A(n) _____ collects a sequence of values of the same type.
variable
algorithm
array
list
36
To find the largest value, update the largest value seen so far whenever you see a larger one
than the final value
than the initial value
no answer
than the expected value
37
A collection of related classes is called a _________.
folder
package
import
utility
38
An immutable class is a class that:
without an accessor method
cannot be changed
is not valuable
without a mutator method
39
If your goal is to find a match, write your program code to exit the loop when:
when the end of file is reached
when the match is found
all entries have been tested
whenever the user decides to quit
40
_____ error, which occurs if you supply an invalid array index, can cause program termination
Bounds
Off-by-one
Index
Array
41
The process of checking each version of a program against a test suite is called
unit testing
regression testing
black box testing
white hat testing
42
What loop is convenient for traversing all elements in an array?
Enhanced WHILE loop
there isn't one
Enhanced FOR loop
Enhanced DO loop
43
Under which conditions would the public interface of a class be considered cohesive?
all features are public & none of its features are static
Quality of public interface is rated as moderate to high
Obvious the public interface refers to multiple concepts
All features are related to concept that class represents
44
First thing you should do when beginning a new object-oriented programming activity is:
Consider how many concepts each class should represent
Determine what categories of classes may be needed
Decide what combo of functions & methods are appropriate
Identify the objects and the classes to which they belong
45
A method that changes the state of an object is called a _______ method.
immutable
mutator
accessor
final
46
What methods are used to access array list elements at a given index?
set and remove
get and set
get and replace
add and delete
47
Individual elements in an array are accessed by integer index i, using the notation _________
array(i)
array[i]
Array[i]
array{i}
48
When collecting values, an _______ or _________ can be used to store the values
object, array
array or array list
array, constant
string, integer
49
Which of the following is one of the most popular testing frameworks?
JQATester
JUnitTest
JTester
JUnit
50
Used to count events & incremented in methods that correspond to the events:
Counter
Class
Constant
Collection
51
An _____ _____ can grow and shrink as needed and is useful when number of inputs is unkown
undefined list
matrix list
sorted list
array list
52
The correct definition for a two-dimensional array of 20 rows & 10 columns of type integer is:
int[][] num = new int [10][20];
int[][] num = new int[20][10];
int[][] num = new int[20,10];
int[][] num = new int [10,20];
53
Why is a static variable also referred to as a class variable?
it is stored in the separate class area of each object
each class has one and only one static variable
It is encapsulated within the class
There is a single copy available to all objects of the class
54
Arrays are intended for storing sequences of values of the __________ type.
sequential
opposite
same
related
55
Which of the following is
NOT
a reason to place classes into a package?
to avoid name clashes (most important)
makes including frequently used but unrelated classes easier
to show authorship of source code for classes
to organize related classes
56
In a three-dimensional array, what are the three index values?
[i][i2][i3]
there's no such thing as a three-dimensional array
[i][j][k]
[i][o][u]
57
To use java.util.Scanner, you must first _______ the package.
export
call
import
write
58
Which statements are true regarding the differences between arrays and array lists?
I & III
II & III
I, II, and III
I & II
59
A method that accesses an object but does not change it is called a ________ method.
final
immutable
mutator
accessor