Services
Discover
Homeschooling
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
Quiz 7: Arrays and Array Lists
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 101
Multiple Choice
Assume the method createSomething has been defined as follows: Int [] createSomething (int start, int size) { Int [] result = new int[size]; For (int i = 0; i < result.length; i++) { Result[i] = start; Start++; } Return result; } What is printed by the statement below? System.out.print (Arrays.toString(createSomething(4, 3) ) ) ;
Question 102
Multiple Choice
Assume the array of integers values has been created and process is a method that has a single integer parameter. Which of the following is equivalent to the loop below? for (int val: values) { Process (val) ; }
Question 103
Multiple Choice
What will be printed by the statements below? ArrayList<String> names = new ArrayList<String>() ; Names.add("Annie") ; Names.add("Bob") ; Names.add("Charles") ; For (int i = 0; i < 3; i++) { String extra = names.get(i) ; Names.add (extra) ; } System.out.print (names) ;
Question 104
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] + " ") ;
Question 105
Multiple Choice
Assume the array of integers values has been created. Which condition must be used in the indicated area so the loop below will assign max the largest value in values? Int max = values[0]; For (int current = 1; current < values.length; current++) { If (/* Put condition here */) Max = values[current]; }
Question 106
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 107
Multiple Choice
What will be printed by the statements below? ArrayList<String> names = new ArrayList<String>() ; Names.add("Annie") ; Names.add("Bob") ; Names.add("Charles") ; Names.set(2, "Doug") ; Names.add(0, "Evelyn") ; System.out.print (names) ;
Question 108
Multiple Choice
What will be printed by the statements below? Int[] values = { 1, 2, 3, 4}; Values[2] = 24; Values[values[0]] = 86; For (int i = 0; i < values.length; i++) System.out.print (values[i] + " ") ;
Question 109
Multiple Choice
Assume the following variable has been declared and given a value as shown: Int[][] data = { {9, 17, -4, 21 }, {15, 24, 0, 9}, {6, 2, -56, 8}, }; Which is the value of data[1][2]?
Question 110
Multiple Choice
Assume the following variable has been declared and given a value as shown: Int[][] data = { {9, 17, -4, 21 }, {15, 24, 0, 9}, {6, 2, -56, 8}, }; Which is the value of data.length?
Question 111
Multiple Choice
What will be printed by the statements below? Int[] values = { 10, 20, 30, 40}; For (int i = 1; i < values.length; i++) Values[i] = values[i - 1]; For (int i = 0; i < values.length; i++) System.out.print (values[i] + " ") ;