stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
Java Chapters 7-9 Flashcards | StudBud
Explore
/
Java Chapters 7-9
Java Chapters 7-9
67 terms
·
StudBud Administration
·
1,250 plays
Arrays, Array Lists, Two-Dimensional Arrays, Classes, Inheritance, Polymorphism
Flashcards
67 cards
F
Practice quiz
P
Host live
L
Questions
67
Answers
1
Any kind of modification of data that is observable outside the method is considered a _____
side effect
intended consequence
unacceptable
unexplainable
2
Which of the following is one of the most popular testing frameworks?
JQATester
JUnitTest
JUnit
JTester
3
What is the difference between a DO Loop and a WHILE Loop?
DO loop always executes once; while doesn't
only the syntax is different
They are the same thing
While loop executes once; Do doesn't
4
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[20,10];
int[][] num = new int [10,20];
int[][] num = new int [10][20];
5
A relationship between a more general class (superclass) & a more specialized class (subclass):
cohesion
polymorphism
inheritance
extension
6
By combining fundamental ________, you can solve complex programming tasks
algorithms
test cases
pseudocode
problems
7
Using the image shown, what is the code doing?
renaming an initialized array
not enough information to know
initializing an array & declaring new array with same values
invalid code - won't compile
8
Objects that move around during the lifetime need to store their position in a ___________
method
class
constant
instance variable
9
What loop is convenient for traversing all elements in an array?
Enhanced FOR loop
Enhanced WHILE loop
there isn't one
Enhanced DO loop
10
You can use the ______ ____ loop to visit all elements of an array.
Compound Do
Enhanced For
Do While
Nested For
11
What loop is best to use when you have a known starting and ending point for your iterations?
WHILE
DO
FOR
GOTO
12
In a three-dimensional array, what are the three index values?
there's no such thing as a three-dimensional array
[i][j][k]
[i][i2][i3]
[i][o][u]
13
A method that changes the state of an object is called a _______ method.
immutable
final
mutator
accessor
14
Which of the following is
NOT
a reason to place classes into a package?
makes including frequently used but unrelated classes easier
to organize related classes
to show authorship of source code for classes
to avoid name clashes (most important)
15
With a partially filled array, you need to keep a companion variable for the current size like:
Counter
currentSize
length
WhereamI
16
An arrangement consisting of rows and columns of values is called a ______ _______or a matrix.
columnar table
elemental table
spread sheet
two-dimensional array
17
When collecting values, an _______ or _________ can be used to store the values
string, integer
object, array
array, constant
array or array list
18
A method that accesses an object but does not change it is called a ________ method.
final
accessor
immutable
mutator
19
Use the expression _________ to find the number of elements in an array.
length.array
array{length}
array.length
array(length)
20
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
all entries have been tested
when the match is found
21
When an array
myArray
is only partially filled, how do you keep track of current # of elements?
access myArray.length()-1
access myArray.currentElements()
maintain a variable that stores the current # of elements
access myArray.length()
22
Why is a static variable also referred to as a class variable?
It is encapsulated within the class
each class has one and only one static variable
There is a single copy available to all objects of the class
it is stored in the separate class area of each object
23
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
24
Individual elements in an array are accessed by integer index i, using the notation _________
array{i}
Array[i]
array[i]
array(i)
25
Means "having multiple forms"
inheritance
polygamy
polymorphism
polytechnic
26
Arrays are intended for storing sequences of values of the __________ type.
opposite
related
sequential
same
27
A ______ search inspects elements in sequence until a match is found.
bubble sort
binary
pop
linear
28
Under which conditions would the public interface of a class be considered cohesive?
all features are public & none of its features are static
Obvious the public interface refers to multiple concepts
All features are related to concept that class represents
Quality of public interface is rated as moderate to high
29
Which statements are true regarding the differences between arrays and array lists?
I & II
II & III
I, II, and III
I & III
30
User runs another program one/few steps at time, stops execution & inspects variables using a:
compiler
tester
variable inspector
debugger
31
Where in a class should static variables be declared and initialized?
Inside the constructor method
Inside the class, but outside of any method body
Outside the class - in a separate designated static class
Outside the class, but inside the same physical file
32
A(n) _____ collects a sequence of values of the same type.
list
algorithm
variable
array
33
Identify the correct statement for defining an integer array named numarray of ten elements:
int[] numarray = new int[9];
int[] numarray = new int[10];
int[10] numarray;
int numarray[10];
34
When an array reading and storing input runs out of space:
program could be recompiled with bigger size for array
the array could be "grown" using growArray method
it automatically resizes to accommodate new elements
array could be "grown" using new command & copyOf method
35
Which of the following most likely indicates that you've chosen a good name for your class?
You can tell by the name what an object of class represents
Can easily determine by name how many concepts represented
Name describes what task the class will perform
The name consists of a single word
36
If your program accesses an array through an out-of-bounds index, what type of error is it?
No error, just hangs
Run-time error
Compiler error
No error, just doesn't computer properly
37
What is the difference between ("4 + 6") and (4 + 6) when used in a print statement?
the first prints the value 10 and the second print 46
the first prints 10 and the second prints 4 + 6
they print the same thing
the first prints 4 + 6 and the second prints 10
38
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
39
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
40
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
41
What is the valid range of index values for an array of size 10?
1 to 10
1 to 9
0 to 9
0 to 10
42
_____ error, which occurs if you supply an invalid array index, can cause program termination
Index
Off-by-one
Bounds
Array
43
To use java.util.Scanner, you must first _______ the package.
import
call
write
export
44
double[] values = new double[10] defines an array of 10 elements with an index range from
unknown
1-10
whatever numbers you set
0-9
45
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
46
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]);
47
When swapping two elements in an array, you need a ________ variable.
paramater
temporary
local
instant
48
What is wrong with this code: double[] = new int[8];
need curly braces instead of square brackets
can't have an array of type int[]
Can't initialize double [] variable with array of type int[]
nothing wrong with this code
49
An immutable class is a class that:
cannot be changed
without an accessor method
is not valuable
without a mutator method
50
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
than the initial value
no answer
51
Features of a class that are accessible to all clients (e.g. methods, variables, etc.) make up:
programs
public interface
private interface
methods
52
Used to count events & incremented in methods that correspond to the events:
Constant
Collection
Counter
Class
53
What methods are used to access array list elements at a given index?
set and remove
add and delete
get and replace
get and set
54
The process of checking each version of a program against a test suite is called
black box testing
white hat testing
unit testing
regression testing
55
This method checks whether two objects have the same contents.
instanceOf
main
equals
toString
56
Saving tests that you use to find program bugs and verify that fixes work into a collection is:
test program
test suite
test group
test cases
57
An array index must be at least ________ and less than the size of the array.
can be any number
none of these
zero
one
58
This reserved word indicates that a class inherits from a superclass.
override
extends
implements
static
59
What does overriding a method do?
ignores a subclass method
replaces functionality of a subclass method
extends or replaces functionality of the superclass method
duplicates a superclass method
60
A collection of related classes is called a _________.
folder
import
utility
package
61
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
62
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 array values is not modified
the elements of the array element are initialized to zero
63
If you don't include a package statement in your class source file, its classes will be placed:
in the default package, which has no name
in java.util
in java.awt
in java.lang
64
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]
65
An _____ _____ can grow and shrink as needed and is useful when number of inputs is unkown
undefined list
matrix list
array list
sorted list
66
This method returns a string representation of each object. It is often used for debugging.
equals
toString
instanceOf
main
67
Which is considered by the text to be the most important consideration when designing a class?
Should represent an appropriate mathematical concept
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