Deck 8: Arrays

Full screen (f)
exit full mode
Question
Many programmers feel that breaking out of a for loop early disrupts the loop flow and makes the code harder to understand.
Use Space or
up arrow
down arrow
to flip the card.
Question
Languages such as Visual Basic, BASIC, and COBOL use ____ to refer to individual array elements.

A) ( )
B) [ ]
C) { }
D) < >
Question
Providing values for all the elements in an array is called ____ the array.

A) populating
B) declaring
C) filling
D) irrigating
Question
After you create an array variable, you still need to ____ memory space.

A) create
B) organize
C) reserve
D) dump
Question
When you create an array variable, memory space is automatically reserved.
Question
When you create an array of objects, each reference is assigned the value ____.

A) null
B) '\u0000'
C) true
D) false
Question
When returning an array reference, square brackets are included with the return type in the method header.
Question
When array elements are passed by value, a copy of the value is made and used within the receiving method.
Question
You use a ____ following the closing brace of an array initialization list.

A) .
B) ;
C) :
D) ,
Question
When you want to determine whether a variable holds one of many valid values, one option is to use a do…while loop to compare the variable to a series of valid values.
Question
A(n) ____ is an integer contained within square brackets that indicates one of an array's variables.

A) postscript
B) subscript
C) variable header
D) indicator
Question
When initializing an array, you must initialize all elements or none.
Question
You can declare an array variable by placing curly brackets after the array name.
Question
In Java, boolean array elements automatically are assigned the value ____.

A) null
B) '\u0000'
C) true
D) false
Question
When using parallel arrays, if one array has many possible matches, it is most efficient to place the less common items first so that they are matched right away.
Question
In Java, the size of an array ____ declared immediately following the array name.

A) can be
B) is always
C) is never
D) should be
Question
When any ____ type (boolean, char, byte, short, int, long, float, or double) is passed to a method, the value is passed.

A) array
B) dummy
C) element
D) primitive
Question
Since an array name is a reference, you are able to use the = operator for assigning and the == operator for comparisons.
Question
When an application contains an array and you want to use every element of the array in some task, it is common to perform loops that vary the loop control variable from 0 to one less than the size of the array.
Question
When you declare an array name, no computer memory address is assigned to it. Instead, the array variable name has the special value ____, or Unicode value '\u0000'.

A) empty
B) null
C) false
D) zero
Question
An instance variable or object field is also called a(n) ____________________ of the object.
Question
When a method returns an array reference, you include ____ with the return type in the method header.

A) { }
B) ( )
C) < >
D) [ ]
Question
A ____ array is one with the same number of elements as another, and for which the values in corresponding elements are related.

A) cloned
B) parallel
C) property
D) two-dimensional
Question
Individual array elements are ____ by value when a copy of the value is made and used within the receiving method.

A) sorted
B) passed
C) received
D) stored
Question
Which of the following statements correctly initializes an array with an initialization list?

A) int[] nums = {2, 4, 8};
B) int[] nums = (2, 4, 8);
C) int nums = [2, 4, 8];
D) int nums() = int{2, 4, 8}
Question
When you declare int[] someNums = new int[10];, each element of someNums has a value of ____________________ because someNums is a numeric array.
Question
In which of the following statements is the value of myVals null?

A) int myVals = ""
B) int [] myVals;
C) myVals = int[null]
D) int[null] = myVals
Question
When you initialize parallel arrays, it is convenient to use ____ so that the values that correspond to each other visually align on the screen or printed page.

A) tabs
B) indentation
C) spacing
D) dashes
Question
When any primitive type is passed to a method, the ____________________ is passed.
Question
A(n) ____ loop allows you to cycle through an array without specifying the starting and ending points for the loop control variable.

A) do…while
B) inner
C) enhanced for
D) enhanced while
Question
Which of the following statements correctly declares and creates an array to hold five double scores values?

A) integer[] scores = new double[5]
B) double[] scores = new integer[5]
C) double[] = new scores[5]
D) double[] scores = new double[5]
Question
When you declare or access an array, you can use any expression to represent the size, as long as the expression is a(n) ____________________.
Question
A(n) ____________________ is a named list of data items that all have the same type.
Question
Primitive type variables are always passed by ____.

A) value
B) reference
C) location
D) memory
Question
If a class has only a default constructor, you must call the constructor using the keyword ____ for each declared array element.

A) default
B) new
C) first
D) object
Question
Comparing a variable to a list of values in an array is a process called ____ an array.

A) validating
B) using
C) checking
D) searching
Question
The length ____ contains the number of elements in the array.

A) box
B) field
C) area
D) block
Question
When you perform a ____, you compare a value to the endpoints of numerical ranges to find the category in which a value belongs.

A) range match
B) sort
C) reference
D) search
Question
Which of the following println statements will display the last myScores element in an array of 10?

A) System.out.println(vals[0]);
B) System.out.println(vals[1]);
C) System.out.println(vals[9]);
D) System.out.println(vals[10]);
Question
It is a good programming practice to ensure that a subscript to an array does not fall below zero, causing a(n) ____.

A) array dump
B) runtime error
C) conundrum
D) compiling error
Question
How can you use the enhanced for loop?
Question
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
A primitive type
Question
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
Numbered beginning with 0
Question
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
Declared in the same way you declare any simple variable
Question
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
A statement used to return an array from a method
Question
How would a programmer perform a range match when writing an application that takes into consideration different discount rates for customers? Give an example.
Question
What does an array's name represent and what value does it hold when declared?
Question
What is different about passing an array to a method rather than passing a primitive type to a method?
Question
When using an array with all elements used, why would a programmer use a loop control variable from 0 to one less than the size of the array? Give an example.
Question
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
Represent computer memory addresses
Question
When working with arrays, why is it beneficial to use a loop with a declared symbolic constant equal to the size of the array?
Question
When populating an array with an initialization list, you do not need to use the new keyword or provide an array size. Explain why this is the case.
Question
Describe a situation in which storing just one value at a time in memory does not meet your needs.
Question
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
Hold memory addresses where values are stored
Question
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
An enhanced for loop
Question
How would you use a method that belongs to an object that is part of the array? Use an example and demonstrate with Java code.
Question
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
An array field
Question
What is a subscript and how are the array's elements numbered?
Question
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
A nonprimitive object
Question
Why would you use spacing when initializing parallel arrays?
Question
Using just one statement, declare and create an array that will reserve memory locations for 10 scores values that are type double.
Question
String[] countyNames = {"Clark", "Delaware", "Madison"};
Using the above statement, what will be the value of countyNames[0], countyNames[1], and countyNames[2]?
Question
public static int[] sampleArray()
{
int studentScores = {72, 91, 83};
____
}
Using the above code, write the statement that will return the array name.
Question
double[] studentScores;
double studentScores[];
Are both of the above statements valid for declaring an array variable? Why or why not?
Question
Write the statement to declare an array variable named studentScores with type double. Write a second statement to create an array of 10 objects.
Question
public class CostArray
{
public static void main(String[] args)
{
double[] costs = new double[3];
costs[0] = 5.00;
costs[1] = 7.00;
costs[2] = 9.00;
System.out.println(costs[3]);
}
}
Once the above code is compiled and executed, an error message is generated. Explain the error message that will result and explain the reason for the error.
Question
Write the statement to create an array named studentScores that will store five integer value student scores. Initialize the array using an initialization list with the values 70, 85, 92, 67, and 76.
Question
String[] countyNames = {"Clark", "Delaware", "Madison"};
What will be the value of countyNames[0].length(), countyNames[1].length(), and countyNames[2].length()?
Question
While you can provide any legal identifier you want for an array, conventional rules are typically followed. List and describe the naming conventions for naming arrays.
Question
double[] studentScores = new double[3];
studentScores[0] = 93;
studentScores[1] = 77;
studentScores[2] = 85;
Write a println statement to display the last element of the studentScores array.
Question
Write the statement to declare an array of integers that will hold studentScores.
Question
int[] sixNumbers = {1, 2, 3, 4};
The above code creates an array named sixNumbers. Describe how array sizes are determined when using an initialization list and how memory is assigned.
Question
The following statement declares an array:
int[] increaseValues = new int[5]
final int PLUSTWO = 2;
Create a loop that will add 2 to every array element. Use a symbolic constant named PLUSTWO and use the length field in the loop that will contain the number of elements in the array.
Question
Why is the length field a good option when writing a loop that manipulates an array? What programming error is common when attempting to use length as an array method?
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/74
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 8: Arrays
1
Many programmers feel that breaking out of a for loop early disrupts the loop flow and makes the code harder to understand.
True
2
Languages such as Visual Basic, BASIC, and COBOL use ____ to refer to individual array elements.

A) ( )
B) [ ]
C) { }
D) < >
A
3
Providing values for all the elements in an array is called ____ the array.

A) populating
B) declaring
C) filling
D) irrigating
A
4
After you create an array variable, you still need to ____ memory space.

A) create
B) organize
C) reserve
D) dump
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
5
When you create an array variable, memory space is automatically reserved.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
6
When you create an array of objects, each reference is assigned the value ____.

A) null
B) '\u0000'
C) true
D) false
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
7
When returning an array reference, square brackets are included with the return type in the method header.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
8
When array elements are passed by value, a copy of the value is made and used within the receiving method.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
9
You use a ____ following the closing brace of an array initialization list.

A) .
B) ;
C) :
D) ,
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
10
When you want to determine whether a variable holds one of many valid values, one option is to use a do…while loop to compare the variable to a series of valid values.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
11
A(n) ____ is an integer contained within square brackets that indicates one of an array's variables.

A) postscript
B) subscript
C) variable header
D) indicator
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
12
When initializing an array, you must initialize all elements or none.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
13
You can declare an array variable by placing curly brackets after the array name.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
14
In Java, boolean array elements automatically are assigned the value ____.

A) null
B) '\u0000'
C) true
D) false
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
15
When using parallel arrays, if one array has many possible matches, it is most efficient to place the less common items first so that they are matched right away.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
16
In Java, the size of an array ____ declared immediately following the array name.

A) can be
B) is always
C) is never
D) should be
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
17
When any ____ type (boolean, char, byte, short, int, long, float, or double) is passed to a method, the value is passed.

A) array
B) dummy
C) element
D) primitive
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
18
Since an array name is a reference, you are able to use the = operator for assigning and the == operator for comparisons.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
19
When an application contains an array and you want to use every element of the array in some task, it is common to perform loops that vary the loop control variable from 0 to one less than the size of the array.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
20
When you declare an array name, no computer memory address is assigned to it. Instead, the array variable name has the special value ____, or Unicode value '\u0000'.

A) empty
B) null
C) false
D) zero
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
21
An instance variable or object field is also called a(n) ____________________ of the object.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
22
When a method returns an array reference, you include ____ with the return type in the method header.

A) { }
B) ( )
C) < >
D) [ ]
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
23
A ____ array is one with the same number of elements as another, and for which the values in corresponding elements are related.

A) cloned
B) parallel
C) property
D) two-dimensional
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
24
Individual array elements are ____ by value when a copy of the value is made and used within the receiving method.

A) sorted
B) passed
C) received
D) stored
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
25
Which of the following statements correctly initializes an array with an initialization list?

A) int[] nums = {2, 4, 8};
B) int[] nums = (2, 4, 8);
C) int nums = [2, 4, 8];
D) int nums() = int{2, 4, 8}
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
26
When you declare int[] someNums = new int[10];, each element of someNums has a value of ____________________ because someNums is a numeric array.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
27
In which of the following statements is the value of myVals null?

A) int myVals = ""
B) int [] myVals;
C) myVals = int[null]
D) int[null] = myVals
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
28
When you initialize parallel arrays, it is convenient to use ____ so that the values that correspond to each other visually align on the screen or printed page.

A) tabs
B) indentation
C) spacing
D) dashes
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
29
When any primitive type is passed to a method, the ____________________ is passed.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
30
A(n) ____ loop allows you to cycle through an array without specifying the starting and ending points for the loop control variable.

A) do…while
B) inner
C) enhanced for
D) enhanced while
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
31
Which of the following statements correctly declares and creates an array to hold five double scores values?

A) integer[] scores = new double[5]
B) double[] scores = new integer[5]
C) double[] = new scores[5]
D) double[] scores = new double[5]
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
32
When you declare or access an array, you can use any expression to represent the size, as long as the expression is a(n) ____________________.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
33
A(n) ____________________ is a named list of data items that all have the same type.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
34
Primitive type variables are always passed by ____.

A) value
B) reference
C) location
D) memory
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
35
If a class has only a default constructor, you must call the constructor using the keyword ____ for each declared array element.

A) default
B) new
C) first
D) object
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
36
Comparing a variable to a list of values in an array is a process called ____ an array.

A) validating
B) using
C) checking
D) searching
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
37
The length ____ contains the number of elements in the array.

A) box
B) field
C) area
D) block
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
38
When you perform a ____, you compare a value to the endpoints of numerical ranges to find the category in which a value belongs.

A) range match
B) sort
C) reference
D) search
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
39
Which of the following println statements will display the last myScores element in an array of 10?

A) System.out.println(vals[0]);
B) System.out.println(vals[1]);
C) System.out.println(vals[9]);
D) System.out.println(vals[10]);
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
40
It is a good programming practice to ensure that a subscript to an array does not fall below zero, causing a(n) ____.

A) array dump
B) runtime error
C) conundrum
D) compiling error
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
41
How can you use the enhanced for loop?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
42
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
A primitive type
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
43
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
Numbered beginning with 0
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
44
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
Declared in the same way you declare any simple variable
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
45
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
A statement used to return an array from a method
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
46
How would a programmer perform a range match when writing an application that takes into consideration different discount rates for customers? Give an example.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
47
What does an array's name represent and what value does it hold when declared?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
48
What is different about passing an array to a method rather than passing a primitive type to a method?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
49
When using an array with all elements used, why would a programmer use a loop control variable from 0 to one less than the size of the array? Give an example.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
50
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
Represent computer memory addresses
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
51
When working with arrays, why is it beneficial to use a loop with a declared symbolic constant equal to the size of the array?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
52
When populating an array with an initialization list, you do not need to use the new keyword or provide an array size. Explain why this is the case.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
53
Describe a situation in which storing just one value at a time in memory does not meet your needs.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
54
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
Hold memory addresses where values are stored
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
55
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
An enhanced for loop
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
56
How would you use a method that belongs to an object that is part of the array? Use an example and demonstrate with Java code.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
57
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
An array field
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
58
What is a subscript and how are the array's elements numbered?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
59
Match each term with the correct statement below.
a.array variable
f.length
b.reference type
g.foreach loop
c.elements
h.reference types
d.int
i.return
e.Java object names
A nonprimitive object
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
60
Why would you use spacing when initializing parallel arrays?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
61
Using just one statement, declare and create an array that will reserve memory locations for 10 scores values that are type double.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
62
String[] countyNames = {"Clark", "Delaware", "Madison"};
Using the above statement, what will be the value of countyNames[0], countyNames[1], and countyNames[2]?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
63
public static int[] sampleArray()
{
int studentScores = {72, 91, 83};
____
}
Using the above code, write the statement that will return the array name.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
64
double[] studentScores;
double studentScores[];
Are both of the above statements valid for declaring an array variable? Why or why not?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
65
Write the statement to declare an array variable named studentScores with type double. Write a second statement to create an array of 10 objects.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
66
public class CostArray
{
public static void main(String[] args)
{
double[] costs = new double[3];
costs[0] = 5.00;
costs[1] = 7.00;
costs[2] = 9.00;
System.out.println(costs[3]);
}
}
Once the above code is compiled and executed, an error message is generated. Explain the error message that will result and explain the reason for the error.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
67
Write the statement to create an array named studentScores that will store five integer value student scores. Initialize the array using an initialization list with the values 70, 85, 92, 67, and 76.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
68
String[] countyNames = {"Clark", "Delaware", "Madison"};
What will be the value of countyNames[0].length(), countyNames[1].length(), and countyNames[2].length()?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
69
While you can provide any legal identifier you want for an array, conventional rules are typically followed. List and describe the naming conventions for naming arrays.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
70
double[] studentScores = new double[3];
studentScores[0] = 93;
studentScores[1] = 77;
studentScores[2] = 85;
Write a println statement to display the last element of the studentScores array.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
71
Write the statement to declare an array of integers that will hold studentScores.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
72
int[] sixNumbers = {1, 2, 3, 4};
The above code creates an array named sixNumbers. Describe how array sizes are determined when using an initialization list and how memory is assigned.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
73
The following statement declares an array:
int[] increaseValues = new int[5]
final int PLUSTWO = 2;
Create a loop that will add 2 to every array element. Use a symbolic constant named PLUSTWO and use the length field in the loop that will contain the number of elements in the array.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
74
Why is the length field a good option when writing a loop that manipulates an array? What programming error is common when attempting to use length as an array method?
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 74 flashcards in this deck.