Arrays

Arrays

1st Grade

9 Qs

quiz-placeholder

Similar activities

Python Math

Python Math

1st - 12th Grade

10 Qs

устройство компьютера, ввод и вывод данных

устройство компьютера, ввод и вывод данных

1st - 5th Grade

10 Qs

Python-basics

Python-basics

1st - 4th Grade

14 Qs

Питонимся

Питонимся

1st - 5th Grade

13 Qs

Array List

Array List

1st Grade

10 Qs

Quiz 1 - Kelas Industri Hummasoft

Quiz 1 - Kelas Industri Hummasoft

1st Grade

11 Qs

Banco de dados - SQL

Banco de dados - SQL

1st Grade

10 Qs

PYTHON (FOR LOOP)

PYTHON (FOR LOOP)

1st - 10th Grade

10 Qs

Arrays

Arrays

Assessment

Quiz

Computers

1st Grade

Medium

Created by

Jose Diaz

Used 4+ times

FREE Resource

9 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

Please select 1 option.

for(String[] row : table){
    System.out.print(row[row.length]);
}

int i = 0;     
for(String[] col : table){
    i++;
    if(i==col.length){
        System.out.print(table[col.length][i]);
    }
}

for(var row : table){
    System.out.print(row[row.length-1]);
}

for(int i=0; i<table.length-1; i++){
    int j = table[i].length-1;
    System.out.print(table[i][j]);
}

2.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

Please select 1 option.

The code will print i = 1 iArr[0] = 1

The code will print i = 1 iArr[0] = 2

The code will print i = 2 iArr[0] = 1

The code will print i = 2 iArr[0] = 2

The code will not compile.

3.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

Please select 1 option.

111

222

It will not compile as bA[0] is uninitialized.

It will throw an exception at runtime.

None of the above.

4.

MULTIPLE SELECT QUESTION

3 mins • 1 pt

Which of the following is/are valid instantiations and initializations of a multi dimensional array?. Please select 2 options.

var array2D =  { { 0, 1, 2, 4}, {5, 6}}

int[][][] array3D = {{0, 1}, {2, 3}, {4, 5}};

int[] array2D[] = new int [2] [2];
array2D[0] [0] = 1;
array2D[0] [1] = 2;
array2D[1] [0] = 3;

int[][] array2D = new int[][]{0, 1};

int[] arr = {1, 2};
int[][] arr2 = {arr, {1, 2}, arr};
int[][][] arr3 = {arr2};

5.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

Please select 1 option.

It will throw an ArrayIndexOutOfBoundsException at Runtime.

It will throw a NullPointerException at Runtime.

It will compile and run without throwing any exceptions

It will compile and throw a NullPointerException at runtime if var ia[][] = { {1, 2}, null }; is replaced with var ia = new int[][]{ {1, 2}, null };.

It will compile and throw a NullPointerException at runtime if var ia[][] = { {1, 2}, null }; is replaced with var ia[][] = new int[][]{ {1, 2}, null };.

6.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

Please select 1 option.

It will throw NullPointerBoundsException.

It will throw ArrayIndexOutOfBoundsException.

It will print null.

It will run without any error but will print nothing.

None of the above.

7.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

Please select 1 option.

The program will fail to compile, because of uninitialized variable 'bool'.

The program will throw a java.lang.NullPointerException when run.

The program will print "0 null false".

The program will print "0 null true".

The program will print null and false but will print junk value for ia[0].

8.

MULTIPLE SELECT QUESTION

3 mins • 1 pt

Which of the following option(s) correctly declare(s) a variable that can directly reference an array of 10 ints?. Please select 2 options.

int[ ] iA

int[10] iA

int iA[ ]

Object[ ] iA

Object[10] iA

9.

MULTIPLE SELECT QUESTION

3 mins • 1 pt

Which of these array declarations and instantiations are legal? . Please select 4 options.

int[ ] a[ ] = new int [5][4] ;

int a[ ][ ] = new int [5][4] ;

int a[ ][ ] = new int [ ][4] ;

int[ ] a[ ] = new int[4][ ] ;

int[ ][ ] a = new int[5][4] ;