Exam 7: Arrays and Array Lists
Exam 1: Introduction98 Questions
Exam 2: Using Objects76 Questions
Exam 3: Implementing Classes103 Questions
Exam 4: Fundamental Data Types125 Questions
Exam 5: Decisions120 Questions
Exam 6: Loops128 Questions
Exam 7: Arrays and Array Lists118 Questions
Exam 8: Designing Classes95 Questions
Exam 9: Inheritance101 Questions
Exam 10: Interfaces85 Questions
Exam 11: Inputoutput and Exception Handling109 Questions
Exam 12: Object-Oriented Design104 Questions
Exam 13: Recursion110 Questions
Exam 14: Sorting and Searching109 Questions
Exam 15: The Java Collections Framework110 Questions
Exam 16: Basic Data Structures104 Questions
Exam 17: Tree Structures110 Questions
Exam 18: Generic Classes75 Questions
Exam 19: Graphical User Interfaces76 Questions
Exam 20: Streams and Binary Inputoutput82 Questions
Exam 21: Multithreading82 Questions
Exam 22: Internet Networking74 Questions
Exam 23: Relational Databases75 Questions
Exam 24: XML74 Questions
Exam 25: Web Applications75 Questions
Select questions type
Which statement is true about the code snippet below? ArrayList<String> names = new ArrayList<String>();
Names.add("John");
Names.add("Jerry");
ArrayList<String> friends = new ArrayList<String>(names);
Friends.add("Harry");
(Multiple Choice)
4.9/5
(36)
) Suppose you wish to process an array of values and eliminate any potential duplicate values stored in the array. Which array algorithms might be adapted for this?
(Multiple Choice)
4.8/5
(31)
Which one of the following is the correct code snippet for calculating the largest value in an integer array list aList?
(Multiple Choice)
4.9/5
(40)
What is the output of the following statements? ArrayList<String> names = new ArrayList<String>();
Names.add("Bob");
Names.add(0, "Ann");
Names.remove(1);
Names.add("Cal");
Names.set(2, "Tony");
For (String s : names)
{
System.out.print(s + ", ");
}
(Multiple Choice)
4.8/5
(37)
Consider the following code snippet:
Int[][] arr =
{
{ 1, 2, 3, 0 },
{ 4, 5, 6, 0 },
{ 0, 0, 0, 0 }
};
Int[][] arr2 = arr;
System.out.println(arr2[2][1] + arr2[1][2]);
What is the output of the given code snippet on execution?
(Multiple Choice)
4.8/5
(40)
Consider the following code snippet:
Int[][] numarray =
{
{ 3, 2, 3 },
{ 0, 0, 0 }
};
System.out.print(numarray[0][0]);
System.out.print(numarray[1][0]);
What is the output of the given code snippet?
(Multiple Choice)
4.9/5
(39)
Assume the following variable has been declared and given a value as shown:
Int[] numbers = {9, 17, -4, 21 };
Which is the value of numbers.length?
(Multiple Choice)
4.8/5
(33)
Which one of the following statements is correct for displaying the value in the third row and the fourth column of a two-dimensional 5 by 6 array?
(Multiple Choice)
4.9/5
(29)
Java 7 introduced enhanced syntax for declaring array lists, which is termed
(Multiple Choice)
4.8/5
(42)
Consider the following code snippet: ArrayList<Integer> arrList = new ArrayList<Integer>();
For (int i = 0; i < arrList.size(); i++)
{
ArrList.add(i + 3);
}
What value is stored in the element of the array list at index 0?
(Multiple Choice)
4.8/5
(33)
Which statement is true about the code snippet below? ArrayList<String> names = new ArrayList<String>();
Names.add("John");
Names.add("Jerry");
ArrayList<String> friends = names;
Friends.add("Harry");
(Multiple Choice)
4.9/5
(39)
Which one of the following code snippets accepts the integer input in an array list named num1 and stores the odd integers of num1 in another array list named oddnum?
(Multiple Choice)
4.8/5
(35)
Which code snippet prints out the elements in a partially filled array of integers?
(Multiple Choice)
4.8/5
(33)
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] + " ");
(Multiple Choice)
4.9/5
(42)
Assume the method doSomething has been defined as follows:
Int [] doSomething (int[] values)
{
Int [] result = new int[values.length - 1];
For (int i = 0; i < result.length; i++)
{
Result[i] = values[i] + values[i + 1];
}
Return result;
}
What is printed by the statements below?
Int [] nums = {3, 18, 29, -2} ;
System.out.print (Arrays.toString(doSomething(nums)));
(Multiple Choice)
4.9/5
(34)
Consider the following code snippet: public static void main(String[] args)
{
ArrayList<String> names = new ArrayList<String>();
Names.add("John");
Names.add("Jerry");
Names.add("Janet");
ArrayList<String> names2 = reverse(names);
}
Public static ArrayList<String> reverse(ArrayList<String> names)
{
ArrayList<String> result = new ArrayList<String>();
For (int i = names.size() - 1; i >= 0; i--)
{
Result.add(names.get(i));
}
Return <String>result;
}
Which statement is true after the main method is executed?
(Multiple Choice)
4.8/5
(36)
Consider the following line of code for calling a method named func1: func1(listData, varData);
Which one of the following method headers is valid for func1, where listData is an integer array list and varData is an integer variable?
(Multiple Choice)
5.0/5
(33)
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]?
(Multiple Choice)
4.8/5
(34)
Select the statement that reveals the logic error in the following method. public static double minimum(double[] data)
{
Double smallest = 0.0;
For (int i = 0; i < data.length; i++)
{
If (data[i] < smallest)
{
Smallest = data[i];
}
}
Return smallest;
}
(Multiple Choice)
4.8/5
(38)
Which statement is true about the code snippet below? public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
ArrayList<Double> inputs = new ArrayList<Double>();
Int ind = 0;
While (in.hasNextDouble())
{
Inputs.set(ind, in.nextDouble());
Ind++;
}
}
(Multiple Choice)
4.8/5
(44)
Showing 81 - 100 of 118
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)