Arrays and Array Lists

# Big Java Binder Early Objects

Computing

## Quiz 7 :Arrays and Array Lists

Showing 1 - 20 of 118
Consider the following line of code: Int[] somearray = new int[30]; Which one of the following options is a valid line of code for displaying the twenty-eighth element of somearray?
Free
Multiple Choice

D

Identify the correct statement for defining an integer array named numarray of ten elements.
Free
Multiple Choice

B

Which one of the following statements is a valid initialization of an array named somearray of ten elements?
Free
Multiple Choice

A

What is the output of the following code snippet? Int[] myarray = { 10, 20, 30, 40, 50 }; System.out.print(myarray[2]); System.out.print(myarray[3]);
Multiple Choice
What is the result of executing this code snippet? Int[] marks = { 90, 45, 67 }; For (int i = 0; i <= 3; i++) { System.out.println(marks[i]); }
Multiple Choice
What is the valid range of index values for an array of size 10?
Multiple Choice
Which one of the following statements is correct about the given code snippet? Int[] somearray = new int[6]; For (int i = 1; i < 6; i++) { Somearray[i] = i + 1; }
Multiple Choice
What is the output of the given code snippet? Int[] mynum = new int[5]; For (int i = 1; i < 5; i++) { Mynum[i] = i + 1; System.out.print(mynum[i]); }
Multiple Choice
Which one of the following statements is correct for the given code snippet? Int[] number = new int[3]; // Line 1 Number[3] = 5; // Line 2
Multiple Choice
What is displayed after executing the given code snippet? Int[] mymarks = new int[10]; Int total = 0; Scanner in = new Scanner(System.in); For (int cnt = 1; cnt <= 10; cnt++) { System.out.print("Enter the marks: "); Mymarks[cnt] = in.nextInt(); Total = total + mymarks[cnt]; } System.out.println(total);
Multiple Choice
When an array myArray is only partially filled, how can the programmer keep track of the current number of elements?
Multiple Choice
Suppose you wish to write a method that returns the sum of the elements in the partially filled array myArray. Which is a reasonable method header?
Multiple Choice
Which code snippet prints out the elements in a partially filled array of integers?
Multiple Choice
In a partially filled array, the number of slots in the array that are not currently used is
Multiple Choice
Complete the following code snippet with the correct enhanced for loop so it iterates over the array without using an index variable. String[] arr = { "abc", "def", "ghi", "jkl" }; ___________________ { System.out.print(str); }
Multiple Choice
Which statements are true about the buffer overrun attack launched over the Internet in 1988? I) The buffer overrun exploited a program that was written in C running on the Unix operating system II) The Java programming language generates a run-time exception when buffer overrun occurs III) In recent years computer attacks have lessened
Multiple Choice