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