comp 2 Flashcards
Aside from the ______ programmers can also declare arrays that holds elements of OBJECTS.
primitive data types,
true or false
Programmers can’t create separate Student objects with unique names.
false
can
To use a method that belongs to an object that is part of an array,
you insert the appropriate subscript notation after the array name and before the dot that precedes the method name.
stud is a _____ that represents each element of emps in turn.
local variable
Using the enhanced for loop :
eliminates the need to use a limiting value for the loop and eliminates the need for a subscript following each element.
In Java, programmers can also
create an array of String objects.
Notice that subject.length; refers to the ______ and NOT TO THE LENGTH OF ANY STRING OBJECTS stored in the subject array.
length of the array subject (three elements)
two things to remember in manipulating arrays of strings
Remember:
Arrays use a length field (no parentheses follow).
String objects use a length() method.
is one with the same number of elements as another, and for which the values in corresponding elements are related.
Parallel Array
Application of Parallel Arrays:
SEARCHING & SORTING.
a variable that holds a value as an indicator of whether some condition has been met. Example: isValid.
Flag
FILL N THE BLANKS!
Searching an array for an exact match is ___ _____ practical.
NOT ALWAYS
comparing a value to the endpoints of numerical ranges to find the category in which a value belongs.
Range Match
The individual array elements are ______
passed by value;
passed by value; that is, a copy of the value is _____
made and used within the receiving method
When any primitive type (boolean, char, byte, short, int, long, float, or double) is passed to a method, the ____ is passed.
value
Arrays, like all nonprimitive objects, are ___; this means that the object actually holds a memory address where the values are stored.
reference types
Arrays, like all nonprimitive objects, are reference type; this means that ______
the object actually holds a memory address where the values are stored.
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.
reference
==
Additionally, when you pass an array (that is, pass its name) to a method, _________.
the receiving method gets a copy of the array’s actual memory address
This means that the receiving method has access
to, and the ability to alter, the original values in the array elements in the calling method.
A method can _______, and when it does, you include _____ with the _____ in the method header.
return an array reference
square brackets
return type
are used as part of the return type; the return statement returns the array name without any brackets.
Square brackets
Call method:
int[] scoresFromMethod = getArray();