p.2
One-Dimensional Arrays
What is the primary benefit of using one-dimensional arrays?
They allow for efficient storage and access of multiple items of the same type.
What does Java do with the initial values of a 2D array?
Counts the initial values to determine the number of rows and columns.
What does the statement 'new double[size]' do in the program?
It allocates a new array of doubles with the specified size.
p.17
Using .length with Arrays
What is the purpose of the Array2DLength class?
To demonstrate the use of .length with a 2D array in Java.
p.13
Creating and Initializing 2D Arrays
What is the syntax to create a 1D int array?
int [ ] list = new int [10];
What is the purpose of the Scanner class in the DynamicArray program?
To read user input for the size of the array.
p.15
Creating and Initializing 2D Arrays
How are elements organized in a 2D array?
Elements are organized in rows and columns, where each row is a 1D array.
p.3
Introduction to Arrays
What is the issue with handling more than four students in the Naive program?
It would require declaring multiple variables, which is impractical.
What does 'array.length' return in the context of the program?
The size of the dynamically allocated array.
p.11
Two-Dimensional Arrays
What is a two-dimensional array?
An array that consists of rows and columns, allowing for the storage of data in a grid format.
p.15
Creating and Initializing 2D Arrays
What is the internal structure of a 2D array?
A 2D array is a composition of multiple 1D arrays.
p.11
Two-Dimensional Arrays
What is an example of a real-world application of two-dimensional arrays?
Storing pixel data for images.
p.4
Processing Arrays with Loops
What does 'mark[8] = 88;' do?
It assigns the value 88 to the ninth element of the array 'mark'.
p.8
Processing Arrays with Loops
What is the purpose of the loop in the ArrayLoop class?
To print each element of the array myArray.
p.1
Introduction to Arrays
What is the primary focus of ITP3914?
Concepts of Data Types and Operations.
p.15
Accessing Elements in 2D Arrays
What does 'myTable[0]' represent in a 2D array?
It represents the first 1D array in the 2D array.
p.4
Introduction to Arrays
What is an array?
An array is a collection of related data put together.
p.13
Creating and Initializing 2D Arrays
What is the syntax to create a 2D array in C?
int [ ][ ] myTable = new int [4][5];
p.13
Creating and Initializing 2D Arrays
What does the variable 'mark' represent in the context?
It is a declaration for a 1D int array.
p.2
One-Dimensional Arrays
What is a one-dimensional array?
A data structure that stores a fixed-size sequence of elements of the same type.
p.8
Processing Arrays with Loops
How are the elements of myArray accessed in the loop?
One by one using their indices.
p.17
Accessing Elements in 2D Arrays
How many columns does each of the first three rows in myTable have?
Each of the first three rows has 5 columns.
What happens to the initial values when an array is created in Java?
The initial values are automatically placed inside the array.
p.4
Processing Arrays with Loops
What is the purpose of the command 'System.out.print(mark[0]);'?
It prints the value of the first element in the array 'mark'.
p.2
One-Dimensional Arrays
How are elements accessed in a one-dimensional array?
Using an index that starts from zero.
p.17
Accessing Elements in 2D Arrays
What does myTable.length return in the given 2D array?
It returns 4, which is the number of rows in the array.
What must be done before using an array?
An array must be created.
p.3
Introduction to Arrays
How is the average calculated in the Naive program?
By summing the grades and dividing by 4.0.
p.9
Using .length with Arrays
What does myArray.length return?
The number of elements in the array.
p.16
Using .length with Arrays
What does myTable[3].length return?
The number of elements in the row myTable[3], which is 5.
p.17
Accessing Elements in 2D Arrays
What does myTable[0].length return?
It returns 5, which is the number of columns in the first row.
How is an array initialized in Java without using the 'new' operator?
By directly assigning values within curly braces, e.g., int[] myArray = {13, 6, 2, 90, 78};
p.3
Introduction to Arrays
What would be a better approach to handle grades for 100 students?
Using an array to store the grades.
p.7
Array Bounds and Exceptions
What is the error encountered when accessing myArray[5]?
java.lang.ArrayIndexOutOfBoundsException.
How do you create an integer array with 10 elements?
int[] mark = new int[10];
p.12
Accessing Elements in 2D Arrays
How would you access the element in the first row and second column of a 2D array named myTable?
System.out.print(myTable[0][1]);
p.11
Accessing Elements in 2D Arrays
How do you access an element in a two-dimensional array?
By specifying the row and column indices.
p.11
Creating and Initializing 2D Arrays
How can you initialize a two-dimensional array?
By using nested braces to define rows and columns.
p.4
Introduction to Arrays
What must all elements in an array have in common?
They must be of the same data type.
p.7
Array Bounds and Exceptions
What is the correct size of myArray in the provided code?
5 elements (indices 0 to 4).
What happens to the initial values in the 2D array?
They are automatically placed inside the array.
How is a 2D array created in the provided Java example?
Through initialization without using the 'new' operator.
How is the size of the dynamically allocated array determined in the program?
By user input using kb.nextInt().
p.3
Introduction to Arrays
What is the purpose of the Naive program?
To calculate the average of four student grades.
p.4
Introduction to Arrays
How are elements in an array indexed?
Elements are indexed with an integer.
p.16
Using .length with Arrays
What does myTable.length return in a 2D array?
The number of rows in the 2D array, which is 4.
p.18
Introduction to Arrays
What is the primary role of a programmer?
To write a complete and precise set of instructions for a computer to solve a particular problem.
p.17
Array Bounds and Exceptions
What happens when you try to access myTable[4].length?
It throws an ArrayIndexOutOfBoundsException because there is no fifth row.
p.18
Introduction to Arrays
What is a problem-solving task in programming?
A specific challenge or issue that requires a solution through coding.
What is the default value of elements in a numerical array?
Elements will be initialized to 0.
p.7
Array Bounds and Exceptions
What happens when you try to access an index outside the bounds of an array?
An ArrayIndexOutOfBoundsException is thrown.
p.2
One-Dimensional Arrays
Can the size of a one-dimensional array be changed after it is created?
No, the size is fixed upon creation.
p.18
Introduction to Arrays
What does a complete set of instructions for a computer entail?
It includes detailed steps that guide the computer in carrying out a specific task.
p.11
Creating and Initializing 2D Arrays
What is the primary use of two-dimensional arrays?
To represent matrices or tables of data.
p.18
Introduction to Arrays
Why is precision important in programming instructions?
Precision ensures that the computer executes the task correctly without errors.
What does Java do when an array is initialized with values?
Java counts the number of initial values and determines the size of the array.
What does 'int num = 10;' represent?
Creating an int variable named 'num' with a value of 10.
p.9
Processing Arrays with Loops
What is the output of the loop in the ArrayLoop class?
It prints the elements of myArray: 13, 6, 2, 90, 78.