chapter 7
the first element in a array is a..
0
what is going to be displayed? System.out.printf( "%02d", 5 );
05
in int[][] b = { {1, 2}, {3, 4} }; the value of b[0][0] is...
1
in int[] n = { 10, 20, 30, 40, 50 }; 10 and 40 are in what index?
10 = n[ 0 ] 40 = n [ 3 ]
what is the variable type to catch array exceptions?
ArrayIndexOutOfBoundsException
when an index of an array that doesn't exist is called, it is known as...
ArrayIndexOutOfBoundsException
how do you create several arrays in one declaration? requirements are 100 elements for b and 27 elements for x. x and b are strings
String[] b = new String[ 100 ], x = new String[ 27 ];
an exception indicates...
a problem that occurs while a program executes
if an element outside the range of an array has been attempted to be accessed, it results in....
a runtime error called ArrayIndexOutOfBoundsException
when an argument is passed by reference, the called method can access the...
argument's value in the caller directly and modify that date if needed,
we think of a array as a reference to a....
array object in memory
a program refers to any array element of an....
array-access expression
how to do you call the length instance variable?
arrayName.length
what is dynamic resizing?
automatically increase their size at execution time to accommodate addition elements
pass by reference is also be called... ( 2 )
call-by-value and call-by-reference
although an objects reference is passed by value, a method can still interact with the referenced object by...
calling its public methods using the copy of the objects reference
java API's prebuilt data structures are called...
collections
data structure definition
collections of related data items
in an enhanced for statement, the type of the parameter much be...
consistent with the type of the elements in the array
exception handling can allow a program to...
continue executing as if no problems occured
a method call be pass two types of values, these are...
copies of primitive values and copies of references to objects
when a argument is passed by value, a...
copy of the args values is passed to the called method
when an argument to a method is an individual array element of a primitive types, the called method receives a...
copy of the elements value
when an argument to a method is an individual array element of a reference types or a whole array, the called method receives a...
copy of the referece
pass by reference improves the performance by eliminating the need to...
copy possibly large amounts of data
exception handling enables you to...
create fault tolerant programs
arrays are
data structures consisting of related data item of the same type
what is a group of variables called? (2)
elements or components
in multidimensional arrays by convention, the first indice identifies the...
elements row
in multidimensional arrays by convention, the second indice identifies the...
elemetns column
how do you format a enhanced for statement?
for ( parameter : arrayname ) statement
you can have as many catch blocks to...
handle different types of exceptions that might be thrown in the corresponding try block.
the catch block can only...
handle exceptions of the specified types ( in the parameter )
catch block contains the code that...
handles the exception if one occurs
constant variables make a program more convenient by...
improving readability ( e.g saying ARRAY_LENGTH instead of saying 10 )
where does the array object store its length of the array?
in the length instance variable
what index does 2 get stored? c[ 4 +1 ] = 2;
index 4
the 0 element is called.... (2)
index zero, zeroth element
the position number of an element is called... (2)
index, subscript
exception suggests that the problem occurs....
infrequently
constant variables must be ______ before they're used.
initialized
multidimensional arrays can be initialized with array....
initializers in declarations
what are ArrayLists?
it is a pre-built data structure that provide and additional function that is dynamic resizing
why do we normally use multiple arrays?
it makes it convenient to process related groups of values
every array object knows its own....
length
an array with m rows and n columns is called an...
m-by-n array
constant variables cannot be ______
modified
how to do format array-access expression?
name[ index ]
how to use call and value in a multidimensional array?can m
name[ row ] [ column ];
constant variables are also called.....
named constants
in int[][] b = { {1, 2}, {3, 4} }; { {1, 2}, {3, 4} } is a...
nested array initializer
are variables declared in the try block accessible in the catch block?
no
can objects themselves be passed to methods?
no
can you use the enhanced for statement to modify elements in a array?
no
when a method works with a copy of a value, does it change the original value?
no
can you change the length instance variable directly? if no, why?
no because its a final
are arrays limited to only a few types?
no, an array can be declared any type
an index has to be....
non negative
what do you the indexed array name in a assign statement?
on the left side of the =
if modify the reference type parameter so that it refers to another object, only the...
parameter refers to the new object, not the original
two ways to pass arguments in method calls in many programming languages are... ( 2 )
pass-by-value and pass-by-reference
how do you handle an exception?
place any code that might throw an exception in a try statement
the elements of can either be ______ types or _____ types
primitive; reference
what type is a Array? (prim or reference)
reference type
in the topic of exceptions.... if the "rule" is that statement normally executes correctly, then the one problem ....
represents the "exception of the rule"
fault tolerant programs can
resolve exceptions
when a array is passed, the receiving method refers to the....
same array object in the caller.
a single element of a array as an argument to a method is called... ( 2 )
scalars or scalar quantities
in order for a method to receive an array reference through a method call, the methods parameter list must....
specify an array parameter with the same type
how do you pass an array argument to a method?
specify the name with about any brackets in the method call
the enhanced for statement eliminates the possibility of...
stepping outside the array
in a array named c, how would you find the sum of the first 3 elements?
sum = c[ 0 ] + c[ 1 ] + c[ 2 ];
multidimensional arrays with two dimensions are often used to represent...
tables of values consisting of information arranged in rows and columns.
when an exception is thrown, the try block...
terminates and the catch block executes...
when declaring an array, the blank [] after the type indicates...
that the name is a variable that will refer to an array
because array bounds checking is performed at execution time, ...
the JVM generates an exception
what is an initializer list?
the brace enclosed comma separated list of values at the end of an array initializer
when no exceptions thrown.... (what happens to the catch block)
the catch blocks are ignored
what is zero-based counting?
the loop control variable is initially 0
what conventions does Array name follow?
the same as other variables
what is a limited capability of arrays?
the size doesn't automatically change
in an enhanced for statement, the identifier represents....
the successive element values in the array on successive iteration of the loop.
the enhanced for statement iterates...
through the elements of an array
when the JVM or a method detects a problem, it ______ an exception
throws
what is zero-based counting normally used for?
to go through arrays
arrays that require two indices to identify a particular element are called....
two dimensional arrays
format a array object creation
type[] name = new type[ #ofElements ];
to pass an individual array element to a method, you....
use the indexed name of the array element as an argument in the method call.
in java, all arguments are passed by...
value
how do you format an array initializer?
variableType[] variableName = { value1, value2, ... };
how do we refer to a particular element in a array? (using words)
we specify the name of the reference to the array and then the position number in an array
what is throwing an exception?
when an exception occurs
how are arrays objects created?
with keyword new
can a program use an expression as an index?
yes
can multidimensional arrays have more than two dimensions?
yes
can you make an array this way? int[] c; c = new int[ 12 ];
yes
can you provide nondefault initial element values when you create an array?
yes
do you need braces for catch and try blocks?
yes
is String b[] = new String[ 100 ]; correct?
yes
what is the default value all array elements receive? for numbers, booleans, and references
zero for numbers, boolean is false, and references get null