Font size
WorksheetsUnderstanding Strings and Arrays
Total questions: 32
Worksheet time: 19mins
What is the process of combining more than one string together known as?
Concatenation
Separation
Division
Multiplication
What is the algorithm to concatenate two strings without using any inbuilt methods?
CONCATENATE (STR1, STR2, STR3)
JOIN (STR1, STR2)
MERGE (STR1, STR2)
LINK (STR1, STR2)
What is a multidimensional array?
An array of arrays
A single-dimensional array
A string array
An object array
How do you create a two-dimensional array in Java?
data_type[1st dimension][2nd dimension][]..[Nth dimension] array_name = new data_type[size1][size2]....[sizeN];
data_type[array_name][size];
array_name[data_type][size];
data_type[size][array_name];
What does a two-dimensional array represent?
A table with rows and columns
A single list of items
A string of characters
A collection of objects
What is the size of a 2D array specified by?
rows and columns
length and width
height and depth
size and capacity
How do you access an element in a two-dimensional array in Java?
array_name[row_index][column_index];
array_name[column_index];
array_name[column_index][row_index];
array_name[row_index];
What happens if you try to access an index outside the bounds of a 2D array?
ArrayIndexOutOfBoundsException is thrown
The program will crash
It returns null
It returns 0
How can you initialize a two-dimensional array with predefined values in Java?
data_type[][] array_name = new data_type[2][2]{{value1, value2}, {value3, value4}};
data_type array_name[][] = new data_type{{value1, value2}, {value3, value4}};
data_type[][] array_name = new data_type[2][2];
data_type[][] array_name = {{value1, value2}, {value3, value4}};
What is the primary purpose of a two-dimensional array?
To represent a single value
To store a single list of items
To create a dynamic list
To store data in a grid format
What is the result of attempting to assign a value to an index that is out of bounds in a two-dimensional array?
Runtime error occurs
The value is assigned to the last index
The program ignores the assignment
It returns a default value
What is the default value of an uninitialized element in a two-dimensional array of integers in Java?
0
NaN
null
undefined
How can you determine the number of rows in a two-dimensional array in Java?
array_name.length;
array_name.size();
array_name.rows();
array_name.getRowCount();
What is the time complexity of accessing an element in a two-dimensional array?
O(1)
O(n)
O(log n)
O(n^2)
What is the maximum number of dimensions a multidimensional array can have in Java?
3
10
2
There is no fixed limit
How do you declare a three-dimensional array in Java?
data_type[array_name][size1][size2];
data_type[3][3][3] array_name;
data_type[1st dimension][2nd dimension][3rd dimension] array_name = new data_type[size1][size2][size3];
data_type[][][] array_name;
What is the result of accessing an element in a two-dimensional array using a negative index?
ArrayIndexOutOfBoundsException is thrown
It returns null
The program will crash
It returns the first element
What is the primary difference between a one-dimensional array and a two-dimensional array?
A one-dimensional array is faster to access than a two-dimensional array.
A one-dimensional array can only hold integers, while a two-dimensional array can hold any data type.
There is no difference; they are the same.
A one-dimensional array stores data in a linear format, while a two-dimensional array stores data in a grid format.
What is the correct way to declare a two-dimensional array of strings in Java?
String array_name[2][2];
String array_name[][];
String[][] array_name;
String[][] array_name = new String[2][2];
What will happen if you try to assign a value to a null two-dimensional array?
It returns a default value
The value is assigned successfully
NullPointerException is thrown
The program will crash
Each piece of data in an array is BEST described as a what?
Integer and string
Item
Element
Elephant
What is meant by 'declaring' an array?
Create an array in a program, specifying its name and size
creating a program, specifying its size
create a program, specifying its name
create an array to assign to a Selection process
Which iteration method is commonly used with arrays?
ELSE
WHILE
IF
FOR
_is a way to classify various types of data such as integer, string, etc.
Dynamic programming
Data Type
Data object
Basic Operations
Explain how to concatenate two strings without using built-in methods.
Explain the process in populating a 3*3 matrix 2D Array.
