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