Computer Science Chapter

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

what is an array

an array is an object that stores a list of values. the entire list can be referenced by its name, and each element in the list can be referenced individually based on its position in the array.

how is an array of objects created

an array of objects is an array of object references. you have to instantiate the array and the objects that are stored in the array must be created separately

what is an array's element type

an array's element type is the type of values that the array can hold. all values in a particular array have the same type, or are at least of compatible types.

describe the process of creating an array. when is memory allocated for the array.

arrays are objects. to create an array, you create a reference to the array (its name). you then instantiate the array itself, which reserves memory space to store the array elements. the only difference between a regular object instantiation and an array instantiation is the bracket syntax.

how are multidimensional arrays implemented in java

as an array of array objects. the arrays that are elements of the outer array could also contain arrays as elements.

what is a command line argument

data that is included on the command line when the interpreter is invoked to execute the program. they are another way to provide input to a program. they are accessed using the array of strings that is passed into the main method as a parameter.

how is each element of an array referenced

each element in an array can be referenced by its numeric position called an index, in the array. in java, all array indexes begin at zero. square brackets are used to specify the index.

explain the concept of array bounds checking. what happens when a java array is indexed with an invalid value.

whenever a reference is made to a particular array element, the index operator (the brackets) ensures that the value of the index is greater than or equal to zero and less than the size of the array. if not, arrayindexoutofboundsexception is thrown

can an entire array be passed as a parameter. how is this accomplished

yes. since an array is an object, a reference to the array is passed to the method. any changes made to the array elements will be reflected outside of the method.

what is an off-by-one error? how does it relate to arrays

occurs when a program's logic exceeds the boundary of an array by one. occur often because indexes start at

how can java methods have variable length parameter lists

use ellipsis (...) in the formal parameter list. when several values are passed into the method, they are automatically converted into an array. this allows the method to be written in terms of array processing without forcing the calling method to create the array.

what does an array initializer list accomplish

used in the declaration of an array to set up the initial values of its elements. an initializer list instantiates the array object, so the new operator is not needed.


Ensembles d'études connexes

Ethical Hacking Network Defense Test (1,000+)

View Set

Database Systems: Design, Implementation, and Management, 11th Edition. Chapter 3 Review Questions

View Set

Mastering A and P Chapter 16 Section 1

View Set