comp 2 Flashcards

1
Q

Aside from the ______ programmers can also declare arrays that holds elements of OBJECTS.

A

primitive data types,

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

true or false

Programmers can’t create separate Student objects with unique names.

A

false

can

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

To use a method that belongs to an object that is part of an array,

A

you insert the appropriate subscript notation after the array name and before the dot that precedes the method name.

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

stud is a _____ that represents each element of emps in turn.

A

local variable

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

Using the enhanced for loop :

A

eliminates the need to use a limiting value for the loop and eliminates the need for a subscript following each element.

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

In Java, programmers can also

A

create an array of String objects.

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

Notice that subject.length; refers to the ______ and NOT TO THE LENGTH OF ANY STRING OBJECTS stored in the subject array.

A

length of the array subject (three elements)

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

two things to remember in manipulating arrays of strings

A

Remember:

Arrays use a length field (no parentheses follow).

String objects use a length() method.

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

is one with the same number of elements as another, and for which the values in corresponding elements are related.

A

Parallel Array

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

Application of Parallel Arrays:

A

SEARCHING & SORTING.

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

a variable that holds a value as an indicator of whether some condition has been met. Example: isValid.

A

Flag

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

FILL N THE BLANKS!

Searching an array for an exact match is ___ _____ practical.

A

NOT ALWAYS

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

comparing a value to the endpoints of numerical ranges to find the category in which a value belongs.

A

Range Match

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

The individual array elements are ______

A

passed by value;

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

passed by value; that is, a copy of the value is _____

A

made and used within the receiving method

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

When any primitive type (boolean, char, byte, short, int, long, float, or double) is passed to a method, the ____ is passed.

A

value

17
Q

Arrays, like all nonprimitive objects, are ___; this means that the object actually holds a memory address where the values are stored.

A

reference types

18
Q

Arrays, like all nonprimitive objects, are reference type; this means that ______

A

the object actually holds a memory address where the values are stored.

19
Q

Because an array name is a ____, you cannot assign another array to it using the _ operator, nor can you compare two arrays using the __ operator.

A

reference

==

20
Q

Additionally, when you pass an array (that is, pass its name) to a method, _________.

A

the receiving method gets a copy of the array’s actual memory address

21
Q

This means that the receiving method has access

A

to, and the ability to alter, the original values in the array elements in the calling method.

22
Q

A method can _______, and when it does, you include _____ with the _____ in the method header.

A

return an array reference
square brackets
return type

23
Q

are used as part of the return type; the return statement returns the array name without any brackets.

A

Square brackets

24
Q

Call method:

A

int[] scoresFromMethod = getArray();