wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Understanding Strings and Arrays

Total questions: 32

Worksheet time: 19mins

Name
Class
Date
1.

What is the process of combining more than one string together known as?

a)

Concatenation

b)

Separation

c)

Division

d)

Multiplication

2.

What is the algorithm to concatenate two strings without using any inbuilt methods?

a)

CONCATENATE (STR1, STR2, STR3)

b)

JOIN (STR1, STR2)

c)

MERGE (STR1, STR2)

d)

LINK (STR1, STR2)

3.

What is a multidimensional array?

a)

An array of arrays

b)

A single-dimensional array

c)

A string array

d)

An object array

4.

How do you create a two-dimensional array in Java?

a)

data_type[1st dimension][2nd dimension][]..[Nth dimension] array_name = new data_type[size1][size2]....[sizeN];

b)

data_type[array_name][size];

c)

array_name[data_type][size];

d)

data_type[size][array_name];

5.

What does a two-dimensional array represent?

a)

A table with rows and columns

b)

A single list of items

c)

A string of characters

d)

A collection of objects

6.

What is the size of a 2D array specified by?

a)

rows and columns

b)

length and width

c)

height and depth

d)

size and capacity

7.

How do you access an element in a two-dimensional array in Java?

a)

array_name[row_index][column_index];

b)

array_name[column_index];

c)

array_name[column_index][row_index];

d)

array_name[row_index];

8.

What happens if you try to access an index outside the bounds of a 2D array?

a)

ArrayIndexOutOfBoundsException is thrown

b)

The program will crash

c)

It returns null

d)

It returns 0

9.

How can you initialize a two-dimensional array with predefined values in Java?

a)

data_type[][] array_name = new data_type[2][2]{{value1, value2}, {value3, value4}};

b)

data_type array_name[][] = new data_type{{value1, value2}, {value3, value4}};

c)

data_type[][] array_name = new data_type[2][2];

d)

data_type[][] array_name = {{value1, value2}, {value3, value4}};

10.

What is the primary purpose of a two-dimensional array?

a)

To represent a single value

b)

To store a single list of items

c)

To create a dynamic list

d)

To store data in a grid format

11.

What is the result of attempting to assign a value to an index that is out of bounds in a two-dimensional array?

a)

Runtime error occurs

b)

The value is assigned to the last index

c)

The program ignores the assignment

d)

It returns a default value

12.

What is the default value of an uninitialized element in a two-dimensional array of integers in Java?

a)

0

b)

NaN

c)

null

d)

undefined

13.

How can you determine the number of rows in a two-dimensional array in Java?

a)

array_name.length;

b)

array_name.size();

c)

array_name.rows();

d)

array_name.getRowCount();

14.

What is the time complexity of accessing an element in a two-dimensional array?

a)

O(1)

b)

O(n)

c)

O(log n)

d)

O(n^2)

15.

What is the maximum number of dimensions a multidimensional array can have in Java?

a)

3

b)

10

c)

2

d)

There is no fixed limit

16.

How do you declare a three-dimensional array in Java?

a)

data_type[array_name][size1][size2];

b)

data_type[3][3][3] array_name;

c)

data_type[1st dimension][2nd dimension][3rd dimension] array_name = new data_type[size1][size2][size3];

d)

data_type[][][] array_name;

17.

What is the result of accessing an element in a two-dimensional array using a negative index?

a)

ArrayIndexOutOfBoundsException is thrown

b)

It returns null

c)

The program will crash

d)

It returns the first element

18.

What is the primary difference between a one-dimensional array and a two-dimensional array?

a)

A one-dimensional array is faster to access than a two-dimensional array.

b)

A one-dimensional array can only hold integers, while a two-dimensional array can hold any data type.

c)

There is no difference; they are the same.

d)

A one-dimensional array stores data in a linear format, while a two-dimensional array stores data in a grid format.

19.

What is the correct way to declare a two-dimensional array of strings in Java?

a)

String array_name[2][2];

b)

String array_name[][];

c)

String[][] array_name;

d)

String[][] array_name = new String[2][2];

20.

What will happen if you try to assign a value to a null two-dimensional array?

a)

It returns a default value

b)

The value is assigned successfully

c)

NullPointerException is thrown

d)

The program will crash

21.
You can declare an array without dimensioning its size, but the size must be determined before you can reference it.
a)
True
b)
False
22.
The value of price.Length is 5
a)
True
b)
False
23.
With the declaration of price, price[1] refers to
a)
2.1
b)
2.2
c)
2.3
d)
2.5
24.
Given an array declared to hold 100 values, the smallest index that can be use with the array is 
a)
based on what index is used when the first value is placed in the array
b)
0
c)
1
d)
undetermined
25.
In an array, every element has the same
a)
data type
b)
subscript
c)
memory location
d)
all of the above
26.

Each piece of data in an array is BEST described as a what?

a)

Integer and string

b)

Item

c)

Element

d)

Elephant

27.
What value is at index 1 in this array?  String[] names = {"Mack", "Dennis", "Dee", "Charlie"};
a)
Mack
b)
Dennis
c)
Dee
d)
Charlie
28.

What is meant by 'declaring' an array?

a)

Create an array in a program, specifying its name and size

b)

creating a program, specifying its size

c)

create a program, specifying its name

d)

create an array to assign to a Selection process

29.

Which iteration method is commonly used with arrays?

a)

ELSE

b)

WHILE

c)

IF

d)

FOR

30.

_is a way to classify various types of data such as integer, string, etc.

a)

Dynamic programming

b)

Data Type

c)

Data object

d)

Basic Operations

31.

Explain how to concatenate two strings without using built-in methods.

4 lines
32.

Explain the process in populating a 3*3 matrix 2D Array.

4 lines