Java Arrays Quiz

Java Arrays Quiz

University

15 Qs

quiz-placeholder

Similar activities

dfc50193-6B-chapter1,2

dfc50193-6B-chapter1,2

University

15 Qs

Informatika

Informatika

University

15 Qs

PHP Quiz 1

PHP Quiz 1

University

20 Qs

Java Programming

Java Programming

University

20 Qs

Array

Array

University

11 Qs

Quiz dmi2

Quiz dmi2

12th Grade - University

10 Qs

Array

Array

University

17 Qs

JDVP Activity

JDVP Activity

12th Grade - University

20 Qs

Java Arrays Quiz

Java Arrays Quiz

Assessment

Quiz

Computers

University

Hard

Created by

Geoff Ewart

FREE Resource

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

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?