Search Header Logo

FA1_Arrays and ArrayLists in Java

Authored by Rabiya Zhexembayeva

Computers

11th Grade

Used 4+ times

FA1_Arrays and ArrayLists in Java
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

18 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the primary purpose of an array in Java?

To manage memory allocation efficiently.

To perform mathematical calculations.

To store multiple values of the same type.

To store values of different types.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you declare an array in Java?

You declare an array in Java using the syntax: 'type[] arrayName;' or 'type arrayName[];'. For example, 'int[] numbers;'. You can also initialize it with 'new type[size]' or with values like 'new type[]{value1, value2, ...}'.

Arrays in Java are declared using 'arrayName: type[];'

You declare an array in Java with 'arrayName = new type[size];'

You can only declare arrays with fixed sizes in Java.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the main difference between an array and an ArrayList?

An ArrayList is always faster than an array in all operations.

The main difference is that an array has a fixed size, whereas an ArrayList can grow and shrink dynamically.

An array is a type of ArrayList that is optimized for performance.

An array can hold different data types, while an ArrayList can only hold one type.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Can an array in Java hold different data types?

An array can hold objects of different classes.

Java arrays can be heterogeneous by default.

Yes, an array can hold different data types.

No, a standard array cannot hold different data types.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you access the first element of an array?

Use arrayName(1) to access the first element of an array.

Access the first element with arrayName.first() method.

The first element can be accessed using arrayName[-1].

Use arrayName[0] to access the first element of an array.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What method is used to find the length of an array?

Use the 'size' function of the array.

Access the first element to determine length.

Count the number of elements manually.

Use the 'length' property of the array.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you iterate through an array using a for loop?

for (int i = 0; i < array.length; i += 2) { // process array[i] }

for (int i = 0; i < array.length; i++) { // process i }

for (int i = 1; i <= array.length; i++) { // process array[i] }

Use a for loop like: for (int i = 0; i < array.length; i++) { // process array[i] }

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?