Search Header Logo

Java Arrays Quiz

Authored by Geoff Ewart

Computers

University

Java Arrays Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you declare an empty array of integers in Java?

int[] myNum = {};

int myNum = [];

int[] myNum = [];

int myNum[] = {};

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to declare an array of strings in Java?

string[] myText;

String[] myText;

str[] myText;

string = myText;

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code? String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; cars[0] = "Opel"; System.out.println(cars[0]);

Volvo

BMW

Opel

Mazda

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code? String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; System.out.println(cars.length);

3

4

5

6

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a valid array declaration in Java?

String myText[];

String myText;

String[] myText;

String myText[] = new String[5];

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a correct way to initialize an array in Java?

String[] cars = new String[4];

String cars[] = {"Volvo", "BMW", "Ford", "Mazda"};

String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};

All of the above

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of using the length property in a for loop when iterating through an array?

To determine the type of elements in the array

To specify how many times the loop should run

To sort the elements in the array

To reverse the elements in the array

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?

Discover more resources for Computers