Study Flashcards
What index value is used to locate the last element in the nums ArrayList?
nums. length()-1
nums. length
nums. size()-1
nums. size()
nums.size()-1
Which method do you use to test if an element is in a set or list named x?
A) x.contain(element)
B) x.include(element)
C) (element instanceof List) || (element instanceof Set)
D) x.in(element)
E) x.contains(element)
E) x.contains(element)
What is the output of the following code?
double[] myList = {1, 5, 5, 5, 5, 1}; double max = myList[0]; int indexOfMax = 0; for (int i = 1; I max) { max = myList[I]; indexOfMax = I; } }
1
Which statement is the correct declaration and initialization of an ArrayList of String values?
A) ArrayList name;
name = ArrayList();
B) ArrayList name; name = new ArrayList();
C) ArrayList name; name = new ArrayList();
D) String name; name = new String();
B) ArrayList name; name = new ArrayList();
How many elements are in array matrix (int[][] matrix = new int[5][5])?
25
How many elements are in array double[] list = new double[5]?
5
Suppose list is a LinkedList that contains 1 million int values. Analyze the following code:
A:
for (int I = 0; I < list.size(); I++)
sum += list.get(i);
B:
for (int i: list)
sum += I;
A) Code fragment A runs as fast as code fragment B.
B) Code fragment A runs faster than code fragment B.
C) Code fragment B runs faster than code fragment A.
C) Code fragment B runs faster than code fragment A.
Because code fragment B uses an iterator to traverse the elements in a linked list
What is the index variable for the element at the first row and first column in array a?
A) a[1][0]
B) a[0][1]
C) a[1][1]
D) a[0][0]
D) a[0][0]
Which statement below is the correct way to retrieve the first element in the nums ArrayList?
nums(0)
nums.get(0)
nums[0]
nums[1]
nums.get(0)
Assume int[][] x = {{1, 2}, {3, 4}, {5, 6}}, what are x.length are x[0].length?
3 and 2
Regression testing is a full or partial selection of already executed test cases which are re-executed to ensure existing functionalities work fine
(T/F)
True
A unit is object-oriented programming is usually considered as
A) a system B) a class C) an interface D) a package
B) a class
Which one of the following best describes a feature provided by Junit?
A) Provides support for documenting source code
B) Provides support for refactoring code
C) Code compilation
D) Provides support to test drivers for running tests
D) Provides support to test drivers for running tests
_______ models has-a relationships and represents an ownership relationship between two objects where the child can exist independently of the parent
Aggregation
________ is a general binary relationship that describes an activity between two classes
Association
_________ models has-a relationships and represents an ownership relationship between two objects where the child cannot exist independent of the parent
Composition
______ can be multi dimensional. (Array or ArrayList)
Array
_______ has a contiguous memory location (Array or ArrayList)
Array
________ cannot store primitive type (Array or ArrayList)
ArrayList
________ holds the constant number of values of the same type (Array or ArrayList)
Array
_______ can only be single dimensional (Array or ArrayList)
ArrayList
_______ automatically grows and shrinks as needed (Array or ArrayList)
ArrayList