Java Array Questions

Java Array Questions

University

50 Qs

quiz-placeholder

Similar activities

CC 101 Final Exam

CC 101 Final Exam

University

50 Qs

Test 4

Test 4

University

50 Qs

Kiến thức về xử lý mảng 1 chiều trong C++

Kiến thức về xử lý mảng 1 chiều trong C++

University

50 Qs

Python Programming - I B.Sc CS quiz

Python Programming - I B.Sc CS quiz

University

50 Qs

SP- Level 2

SP- Level 2

5th Grade - Professional Development

50 Qs

GIS Revision Unit I & II

GIS Revision Unit I & II

University

45 Qs

UH 1 Berpikir Komputasional

UH 1 Berpikir Komputasional

10th Grade - University

50 Qs

PHP Basics

PHP Basics

University

54 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

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