comp 1 Flashcards

1
Q

is a named list of data items that all have the same data type.

A

Array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

data items of an Array.

A

Element

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Array declaration:

A

Syntax: datatype[] ArrayName; or datatype ArrayName[];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

NOTE: the preferred format among Java programmers is to

A

place the brackets following the variable type and before the variable name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

After creating an array variable,

A

you need to reserve memory space.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Syntax:

A

ArrayName = new datatype[number of elements];

or

Datatype[] Arrayname = new datatype[number of elements];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

is an integer contained within square brackets that specifies one of an array’s elements.

A

Subscript (sub for short) -

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

They are also called index, which can be seen in error messages in compiler.

A

sub

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

NOTE: An array elements are numbered beginning with _

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When you declare int[] someNums = new int[10];, someNums holds an _____

A

address

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

but each element of someNums has a value of 0 by default because someNums is an

A

integer array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The following default values are used for different array types:

A

Each element in an int array is assigned 0.
Each element in a double or float array is assigned 0.0
Each element in a char array is assigned \u0000, which is the Unicode value for a null character.
Each element in a Boolean array is assigned the value false.
Each element in an array of objects, including Strings, is assigned null by default.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

To initialize an array, use an____separated by commas and enclose within curly braces.

A

initialization list of values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

is called when the programmer provides values to all the elements of the array.

A

Populating the array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Common programmer error is

A

to attempt to use length as an array method -> scoreArray.length();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

The length in ____ is NOT A METHOD, it is a ___ (also called property of the object)

A

array
FIELD

17
Q

a loop that allow the program to iterate though an array without specifying the starting and ending points for the loop control variable.

A

Enhanced for loop