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
When a Java program terminates and reports an exception, the error message contains which pieces of useful information?
I. The compile and revision control history of the source code changes that caused the error
II. The name of the exception that occurred
III. The stack trace
(Multiple Choice)
5.0/5
(36)
What is the output of the code snippet below?
Int[][] arr =
{
{ 1, 2, 3, 0 },
{ 4, 5, 6, 0 },
{ 0, 0, 0, 0 }
};
Int val = arr[1][2] + arr[1][3];
System.out.println(val);
(Multiple Choice)
4.8/5
(47)
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)
4.8/5
(34)
Which one of the following is the correct header for a method named arrMeth that is called like this: arrMeth(intArray); // intArray is an integer array of size 3
(Multiple Choice)
4.8/5
(37)
What will be printed by the statements below?
Int[] values = { 4, 5, 6, 7};
Values[0] = values[3];
Values[3] = values[0];
For (int i = 0; i < values.length; i++)
System.out.print (values[i] + " ");
(Multiple Choice)
4.9/5
(37)
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)
5.0/5
(41)
What is the output of the following code?
Int[][] counts =
{
{ 0, 0, 1 },
{ 0, 1, 1, 2 },
{ 0, 0, 1, 4, 5 },
{ 0, 2 }
};
System.out.println(counts[3].length);
(Multiple Choice)
4.8/5
(30)
Consider the following code snippet:
Int[][] arr =
{
{ 1, 2, 3 },
{ 4, 5, 6 }
};
Int val = arr[0][2] + arr[1][2];
System.out.println(val);
What is the output of the given code snippet on execution?
(Multiple Choice)
4.8/5
(40)
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);
(Multiple Choice)
4.9/5
(34)
What should you check for when calculating the largest value in an array list?
(Multiple Choice)
4.9/5
(44)
Which one of the following is a correct declaration for a method named passAList with the array list num of size 5 as a parameter?
(Multiple Choice)
4.7/5
(34)
When the order of the elements is unimportant, what is the most efficient way to remove an element from an array?
(Multiple Choice)
4.9/5
(45)
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);
(Multiple Choice)
4.9/5
(36)
Which code snippet finds the largest value in an array that is only partially full?
(Multiple Choice)
4.8/5
(37)
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(1, "Tony");
For (String s : names)
{
System.out.print(s + ", ");
}
(Multiple Choice)
4.8/5
(41)
Consider the following code snippet: String[] data = { "123", "ghi", "jkl", "def", "%&*" };
Which statement sorts the data array in ascending order?
(Multiple Choice)
4.8/5
(45)
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)
4.9/5
(38)
How many elements can be stored in a two-dimensional 5 by 6 array?
(Multiple Choice)
4.8/5
(33)
It may be necessary to "grow" an array when reading inputs because
(Multiple Choice)
5.0/5
(27)
Showing 21 - 40 of 118
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)