Data Structures & Algorithms Quiz

Data Structures & Algorithms Quiz

Assessment

Flashcard

Other

2nd Grade

Hard

Created by

John Alvin Omiles

FREE Resource

Student preview

quiz-placeholder

51 questions

Show all answers

1.

FLASHCARD QUESTION

Front

What will the output be for the code snippet: int[] arr1 = {1, 2, 3}; int[] arr2 = new int[3]; arr2 = arr1; arr2[0] = 10; System.out.println(arr1[0]);?

Back

B) 10

2.

FLASHCARD QUESTION

Front

Which of the following code snippets will result in a compilation error?

Back

C) char letters[] = new char[3]; letters[3] = 'A';

3.

FLASHCARD QUESTION

Front

What will be the output of the following code: int[] arr = {1, 2, 3, 4}; System.out.println(arr[arr.length - 1]);?

Back

B) 4

4.

FLASHCARD QUESTION

Front

What will happen when the following code is executed: String[] fruits = {"Apple", "Banana", "Orange"}; System.out.println(fruits[fruits.length]);?

Back

C) An ArrayIndexOutOfBoundsException will be thrown.

5.

FLASHCARD QUESTION

Front

If the base address in a 1D integer array arr is 2000, and each integer takes 4 bytes, what will be the address of the 5th element (arr[4])?

Back

C) 2016

6.

FLASHCARD QUESTION

Front

Identify the issue in the following computed addressing formula in a 1D Array: Address = Base Address + (Index + 1) * Element Size

Back

A) It will compute the wrong address for the first element.

7.

FLASHCARD QUESTION

Front

If ArrayKo is an integer array having 6 elements with a base address of 1000, and each integer occupies 2 bytes, what happens if you try to access A[6]?

Back

C) It will result in an out-of-bounds error if the array has more than 6 elements.

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?