Services
Discover
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
Big Java Binder Early Objects
Exam 7: Arrays and Array Lists
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 1
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?
Question 2
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]) ; }
Question 3
Multiple Choice
The following statement gets an element from position 4 in an array: x = a[4]; What is the equivalent operation using an array list?
Question 4
Multiple Choice
Identify the correct statement for defining an integer array named numarray of ten elements.
Question 5
Multiple Choice
Consider the following code snippet: public static void check(ArrayList<Integer> chknum1) { Int cnt = 0; For(int i = 0; i < chknum1.size() ; i++) { If(chknum1.get(i) == 0) { Cnt++; } } System.out.println("The total 0 values in the list are: " + cnt) ; } Which one of the following is true about the check method in the given code snippet?
Question 6
Multiple Choice
What is the output of the following code snippet? public static int check(ArrayList<Integer> listData) { Int sum = 0; For (int i = 0; i < listData.size() ; i++) { Sum = sum + listData.get(i) ; } Return sum; } Public static void main(String[] args) { ArrayList<Integer> vdata = new ArrayList<Integer>() ; Int rsum; For (int cnt = 0; cnt < 3; cnt++) { Vdata.add(cnt + 1) ; } Rsum = check(vdata) ; System.out.println(rsum) ; }
Question 7
Multiple Choice
The enhanced for loop
Question 8
Multiple Choice
Consider the telephone book as a physical object that can help understand algorithms. What kind of algorithm might be visualized using it?
Question 9
Multiple Choice
Which one of the following is a valid signature of a method with an integer two-dimensional array parameter of size 10 x 10?
Question 10
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
Question 11
Multiple Choice
The integer array numbers will be filled with the values from the Scanner in. If there are more input values than there are spaces in the array, only enough values to fill the array should be read. The integer variable currentSize should be set to the number of values read. Partial code to do this is given below: Int[] numbers; // Assume it is created with at least 1 space Scanner in = new Scanner (System.in) ; Int currentSize = 0; While (/* Put condition here */) { Int value = in.nextInt() ; Numbers[currentSize] = value; CurrentSize++; } What condition will complete this code?
Question 12
Multiple Choice
Which one of the following statements is true about passing arrays to a method?
Question 13
Multiple Choice
What will be printed by the statements below? Int[] values = { 4, 5, 6, 7}; For (int i = 1; i < values.length; i++) Values[i] = values[i - 1] + values[i]; For (int i = 0; i < values.length; i++) System.out.print (values[i] + " ") ;