Search Header Logo

Arrays

Authored by Jose Diaz

Computers

1st Grade

Used 5+ times

Arrays
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

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].

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?