Chapter 9: Arrays

0.0(0)
Studied by 1 person
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/13

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:45 AM on 11/18/24
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

14 Terms

1
New cards

What is an array?

A data structure that stores a collection of elements, all of the same type.

2
New cards

What is the index of the first element in an array?

3
New cards

How do you declare an array in Java?

You can declare an array using 'int[] numbers;' or 'int numbers[];'. The preferred method is 'int[] numbers;'.

4
New cards

What must an array be initialized with?

An array must be initialized with a specific size or with values.

5
New cards

How do you access the first element of an array named 'numbers'?

You access it using 'numbers[0]'.

6
New cards

What does the length property of an array represent?

It gives the number of elements in the array.

7
New cards

How do you declare a 2D array in Java?

You can declare it using 'int[][] matrix = new int[3][4];'.

8
New cards

What does the enhanced for loop do?

It simplifies iteration over arrays.

9
New cards

How are arrays passed to methods in Java?

Arrays are passed by reference, allowing methods to modify the original array.

10
New cards

What exception is thrown when accessing an invalid index of an array?

ArrayIndexOutOfBoundsException.

11
New cards

Can arrays store objects in Java?

Yes, arrays can store objects, not just primitive types.

12
New cards

What happens when an array is instantiated in Java?

Java automatically initializes the components to their default values; for integers, this is 0.

13
New cards

What is the syntax for declaring an array with a fixed number of components?

First the data type followed by brackets, e.g., 'int[] alhs = new int[6];'.

14
New cards

What is the correct declaration for multiple arrays of the same type?

Use 'int[] alpha, beta;' to ensure both variables are arrays.