Java Array Questions

Java Array Questions

University

โ€ข

50 Qs

quiz-placeholder

Similar activities

IP Address

IP Address

University

โ€ข

50 Qs

Grade 10 Computer Systems Quiz

Grade 10 Computer Systems Quiz

10th Grade - University

โ€ข

50 Qs

Parcial Nยฐ1 - Mantenimiento y Pruebas de Software

Parcial Nยฐ1 - Mantenimiento y Pruebas de Software

University

โ€ข

47 Qs

SAS Mapel Pilihan XI

SAS Mapel Pilihan XI

11th Grade - University

โ€ข

50 Qs

Technical Quiz 2022-23

Technical Quiz 2022-23

University

โ€ข

50 Qs

CBT - Revision # 3

CBT - Revision # 3

12th Grade - University

โ€ข

54 Qs

ES084 Final Exam

ES084 Final Exam

University

โ€ข

50 Qs

XIRPL2_PASQUIZZ

XIRPL2_PASQUIZZ

1st Grade - Professional Development

โ€ข

50 Qs

Java Array Questions

Java Array Questions

Assessment

Quiz

โ€ข

Computers

โ€ข

University

โ€ข

Practice Problem

โ€ข

Easy

Created by

Satish T

Used 4+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

50 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec โ€ข 1 pt

What is the output? int[] a = {1, 2, 3, 4, 5}; System.out.println(a[a.length - 1]);

1

4

5 (Correct)

Compilation error

2.

MULTIPLE CHOICE QUESTION

30 sec โ€ข 1 pt

What will happen? int[][] m = new int[2][2]; System.out.println(m[1][1]);

0 (Correct)

Compilation error

NullPointerException

ArrayIndexOutOfBoundsException

3.

MULTIPLE CHOICE QUESTION

30 sec โ€ข 1 pt

What will be printed? int[] a = {5, 4, 3}; System.out.println(a[-1]);

5

-1

ArrayIndexOutOfBoundsException (Correct)

Compilation error

4.

MULTIPLE CHOICE QUESTION

30 sec โ€ข 1 pt

Identify the result of the following snippet: int[][] arr = new int[2]; arr[0] = new int[2]; arr[1] = new int[3]; System.out.println(arr[1].length);

2

3 (Correct)

1

Compilation error

5.

MULTIPLE CHOICE QUESTION

30 sec โ€ข 1 pt

Which is valid declaration?

int arr[] = new int[3]; (Correct)

int[3] arr = new int[];

int[] arr = new int[];

int arr = new int[3];

6.

MULTIPLE CHOICE QUESTION

30 sec โ€ข 1 pt

What is the output? int[] a = {1, 2, 3, 4, 5}; System.out.println(a[a.length - 1]);

1

4

5 (Correct)

Compilation error

7.

MULTIPLE CHOICE QUESTION

30 sec โ€ข 1 pt

What is the output? int[] x = new int[]{1, 2, 3}; x = new int[]{4, 5}; System.out.println(x[1]);

1

2

5 (Correct)

Compilation error

Create a free account and access millions of resources

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?