Chapter 6 and Chapter 7
the variable that holds the count of times in the array must also be passed as an argument.
If a partially filled array is passed as an argument to a method,
null, they do not reference anything.
If an object has any fields that are reference variables, the default constructor sets them to
the dependent item is said to be stale.
When the value of an item is dependent on other data, and that item is not updated with the other data is changed, then
shadows the name of the field.
When you have local variable or a parameter variable with the same name as a field, it is said that the local or parameter variable
process only the elements that contain valid data items.
When you process a partially filled array, you must
compares the memory addresses not the contents of the object.
When you use the == operators with reference variables, including array references, the operator
for (int row = 0; row < numbers.length ; row++) { for (int col = 0; col < numbers[row].length ; col++) System.out.println(numbers[row][col]); }
Write code to display the arrays of any number of rows and columns:
provide a method that returns the result of a calculation.
To avoid storing stale data,
compare the elements of the two elements.
To compare the contents of two arrays, you must
copy the individual elements of one array to the other array, usually using a loop.
To copy an array, you need to
nested loops.
2D arrays are processed with programs that have
a code that describes a particular object.
A class is
description of an object.
A class is not an object, but a
a code blueprint that can be used to create a particular type of object.
A class may be thought of as
The things that class is responsible for knowing (attributes) and the actions that the class is responsible for doing (methods.)
A class's responsibilities are
privately, which prevents them from being accessed by statements outside the class.
A class's variable fields are usually declared
name as the class.
A constructor has the same
a method that is automatically called when an object is created, they help construct an object.
A constructor is
no-arg constructor.
A constructor that does not accept arguments is known as a
reference an object before it can be used.
A local reference variable must
accessor method.
A method that get's a value from a class's field but does not change it is known as a
mutator method.
A method that stores a value in a field or changes the value of a field in some other way is known as a
part of a method's signature.
A method's return type is not
the method's name and the data types of the parameters.
A method's signature consists of
simply a group of related classes.
A package is
because a variable created with a primitive data type has no capabilities other than storing a value.
A primitive data type is called primitive
it holds the object's memory address.
A reference variable does not hold data, instead
an array of one dimensional arrays.
A two dimensional array can be thought of as
multiple values of the same data type simultaneously.
An array can hold
an array of references to String objects.
An array of String objects is really
the number of elements in the array.
An array's length field contains
the specific package location of a single class.
An explicit import statement tells the compiler
a software component that exists in memory and serves a specific purpose in a program.
An object is
two separate entities.
Because an array is an object, the array and its reference variable are
no-arg constructor.
Because it doesn't accept arguments, the default constructor is considered a
must be created in memory.
Before a specific type of object can be used by a program, that object
you must have a class for the object.
Before an object can be created in memory,
length
Both Array and String objects have a method named
No.
Does declaring an array reference variable create an array?
No.
Does using the wildcard import statement affect the performance or size of your program?
two subscripts.
Each element in a 2D array has
subscript.
Each element in an array is assigned a number reference known as a
an instance of the class.
Each object that is created from a class is called
different parameters.
Each version of a constructor must have
int[][] ragged = new int[4];
How do you create a ragged array
name.remove(2)
How do you remove the third element of an ArrayList named name?
use the size method: name.size()
How do you retrieve the number of elements in an ArrayList?
use the get method: name.get(2)
How do you retrieve the value of the thrid element in an ArrayList?
The smallest value in the array is located and moved to/swapped with element 0. Then the next smallest is located and moved to element 1. This process continues until all of the elements have been placed in their proper order.
How does a selection sort work?
virtually any number of dimensions.
How many dimensions does Java allow you create for arrays
Two, one holding the number of rows and another holding the number of columns.
How many length fields does a Two Dimensional array have?
the class's members.
In general, the fields and methods that belong to a class are referred to as
it can store data, commonly called fields OR it can perform operations, aka methods.
In software, an object has two general capabilities:
all of the class's instance methods.
Instance fields are visible to
static
Instance methods do not have the keyword _______ in their header.
private, public.
It is common to have _________ fields and _________ methods that access those fields.
a final variable.
It is commonplace to use this as a size declarator when creating a new array
an new array is created with an initialization list of values, the compiler determines the size based on the number of items in the list.
Java automatically creates an array and stores the values when
at runtime.
Java does not allow a statement to use a subscript outside of the valid range, bounds checking occurs
it automatically expands as items are added to it, you can remove items as well as adding items, and it automatically shrinks when items are removed.
Some advantages of an array list over an array are
Scanner object for reading input from the keyboard, the Random object for generating a random number, the PrintWriter object to write output to a file.
Some examples of objects are:
1) Write out the problem domain 2) Identify all the nouns 3) Refine the list of nouns.
Three steps that can be used to identify the classes for a program are
signature
Java uses a method's _________ to distinguish it from other methods with the same name.
null.
Java uses this value to initialize array elements that do not yet reference objects
initialized or assigned a value before they can be used.
Local variables must be
import an API class in order to use it.
Many of the classes in the Java API are not automatically included, so you have to
cannot be changed.
Once an array is created, it's size
It creates an object from the Random class, and returns that object's memory address to the rand variable.
Random rand = new Random(); What does "new Random()" do in the expression above?
an uninitialized reference variable, it does not create an object. It only creates a variable that can reference an object.
Rectangle box; is an example of
class type variables, and can only be used to reference objects.
Reference variables are also known as
int sum = 0; for (int row = 0; row < a2d.length; row++) { for (int col = 0; col < a2d[row].length; col++) sum += a2d[row][col]; }
Sum the values of a two dimensional array
reference copy.
The assignment operation int[] array2 = array1; creates a
0 and false.
The default constructor sets all of the object's numeric fields to ___ and boolean fields to ___
when you need to change the contents of a single array element, or when you need to work in reverse order, or when not all elements need to be accessed, or when 2 or more arrays need to simultaneously worked on, or when a particular subscript needs to be referred to.
The enhanced for loop is a great many circumstances, but 5 cases in which the traditional for loop should be used are:
array.length - 1.
The largest subscript of an array is given by
the string class.
The one class that can be instantiated without the new operator is
you do not write your own constructor for the class.
The only time Java provides a default constructor is when
the set of real-world objects, parties, and major events related to the problem.
The problem domain is
binding.
The process of matching an overloaded method call with the correct method is called
name, fields, and the methods.
The three parts of a UML for a class are
cause elusive bugs, so you need to be careful not to give local variables the same name as fields.
The unintentional shadowing of field names can
to import all of the classes in a package.
The wildcard import statement tells the compiler
explicit and wildcard.
There are two types of import statements:
multiple sets of data, ie. they have rows and columns.
Two-dimensional arrays, aka 2D arrays, hold
arrays.
Varargs parameters are actually
to model data that occurs in multiple sets.
What is the purpose of creating arrays with multiple dimensions
for (datatype elementVariable : array) {statements;}
What is the syntax for an enhanced for loop:
ArrayList<String> name = new ArrayList<String>();
What is the syntax for creating an ArrayList String object
is designed to work on an instance of the class, it is an instance method.
When a method header does not include static, the method
that multiple methods in the same class have the same name but use different parameters.
When a method is overloaded it means,
not passed, the reference to the array is passed into the parameter.
When an entire array is passed into a method, the actual array is
UML diagram, Unified Modeling Language.
When designing a class it is often helpful to draw a
enclose each row's initialization list in its own set of braces.
When initializing a two-dimensional array, you
the parameter must be declared as a reference to a 2d array.
When passing a two-dimensional array to a method,
cannot, methods that are members of the same class.
When the private access specifier is applied to a class member, the member ____________ be accessed by code outside the class. It can only be accessed by _____________
a ragged array.
When the rows of a two-dimensional array are of different lengths, the array is known as
the new operator.
You create primitive variables with simple declaration statements, and you create objects with
java.lang package.
You do not have to write an import statement for any class that is part of the
the fact that the int method accepts a varargs parameter, it can take a variable number of arguments.
in the header public static int sum(int... numbers) the ... refer to
numbers sub zero is assigned 20.
numbers[0] = 20 is read as