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