Java Final Exam Review

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Viet Ho
Viet Ho, Software development
Viet, a versatile software developer, proficient in the development stack, excels in front-end with Svelte, TypeScript, and JavaScript. He's skilled in CSS, CSS libraries, Spring framework, Java, Golang, and MySQL. He thrives in Agile teamwork.
Quizzes Created: 2 | Total Attempts: 434
| Attempts: 298 | Questions: 19
Please wait...
Question 1 / 19
0 %
0/100
Score 0/100
1. A tree in which each node may have at most two children is called a(n) _____ tree.

Explanation

A tree in which each node may have at most two children is called a binary tree. In a binary tree, each node can have either zero, one, or two children. This type of tree is commonly used in computer science and data structures. The term "binary" refers to the fact that each node has two possible children.

Submit
Please wait...
About This Quiz
Java Final Exam Review - Quiz

This Java Final Exam Review assesses key concepts in Java programming, focusing on iterators, list manipulation, and generics. It is designed to test understanding and application of Java's... see morecore features, critical for any aspiring software developer. see less

2. Assume you have an array of unsorted items that allows duplicate entries and that the item you aresearching for is present. Using an iterative sequential search on an unsorted array, the loop exits when

Explanation

In an iterative sequential search on an unsorted array, the loop exits when it locates the first entry in the array that matches the item being searched for. This means that as soon as a match is found, the loop stops and the search is considered successful. The search does not continue to find any other matching entries in the array.

Submit
3. In the IteratorForLinkedList class, the hasNext method determines iteration has ended by

Explanation

The correct answer is to check if the nextNode variable is null. This is because in a linked list, each node has a reference to the next node in the list. So, if the nextNode variable is null, it means that there are no more nodes left to iterate over, indicating that the iteration has ended.

Submit
4. Writing "? super T" where T defines a generic type means

Explanation

Writing "? super T" where T defines a generic type means that the type parameter T can be replaced with any super class of T. This allows for flexibility in the type hierarchy, as any super class of T can be used in place of T. This is useful when defining generic methods or classes that need to accept a wide range of types.

Submit
5. Which method is declared to be protected in the LinkedChainBase class?

Explanation

The correct answer is "all of the above" because all three methods - addFirstNode, addAfterNode, and removeAfterNode - are declared as protected in the LinkedChainBase class. Being declared as protected means that these methods can only be accessed within the class itself and its subclasses, providing encapsulation and allowing for controlled access to these methods.

Submit
6. The constructor in the SeparateIterator class

Explanation

The constructor in the SeparateIterator class initializes the iterator so it begins at the first entry in the list and connects the iterator to the list in question. This means that when the SeparateIterator object is created, it is set to point to the first entry in the list and is ready to iterate through the elements of the list. Therefore, the correct answer is both a & b.

Submit
7. To prevent a subclass from overriding protected methods, we declare them to be

Explanation

Final keyword is used in Java to prevent a method from being overridden in a subclass. When a method is declared as final, it cannot be modified or overridden by any subclass. In the given question, the correct answer is "final" because it is the keyword that prevents a subclass from overriding protected methods. Protected methods can still be accessed by subclasses, but if they are declared as final, they cannot be overridden.

Submit
8. Classes that implement the Comparable interface must define

Explanation

Classes that implement the Comparable interface must define the compareTo method. This method is used to compare objects of the class and determine their order. It returns a negative integer if the current object is less than the object being compared, zero if they are equal, and a positive integer if the current object is greater. The other methods mentioned (equals, lessThan, notEquals) are not required by the Comparable interface and may or may not be implemented depending on the specific needs of the class.

Submit
9. A node in a binary tree is an object that references a data object and

Explanation

A node in a binary tree is an object that references a data object and two child nodes in a tree. In a binary tree, each node can have at most two child nodes, commonly referred to as the left child and the right child. These child nodes can also be considered as separate nodes in the tree. Therefore, the correct answer is that a node in a binary tree references two child nodes in a tree.

Submit
10. In a binary tree, if both the left and right child of a node are null

Explanation

If both the left and right child of a node in a binary tree are null, it means that the node does not have any further child nodes. This indicates that the node is a leaf node, which is a node that does not have any children. Therefore, the correct answer is that the node is a leaf.

Submit
11. A node with no children is called a(n) _____.

Explanation

A node with no children is called a leaf because it is the end point of a tree branch. It does not have any child nodes branching off from it, hence it is referred to as a leaf node.

Submit
12. What does the hasNext method return when the list is empty?

Explanation

The hasNext method returns false when the list is empty because there are no elements in the list to iterate over.

Submit
13. Hashing is a good technique for implementing a dictionary when _____ is the primary task.

Explanation

Hashing is a good technique for implementing a dictionary when searching is the primary task because it allows for efficient retrieval of data. Hashing involves using a hash function to map keys to indexes in an array, making it easy to locate the desired value by directly accessing the corresponding index. This results in constant time complexity for searching, making it an ideal choice for scenarios where quick retrieval of data is required.

Submit
14. Nodes that are children of the same parent node are called _____.

Explanation

Nodes that are children of the same parent node are called siblings. Siblings share the same parent node and are at the same level in the tree structure. They are connected through their common parent and do not have any direct hierarchical relationship with each other. Therefore, the correct answer is siblings.

Submit
15. A separate class iterator is a good choice when

Explanation

When an ADT's implementation does not have an iterator and cannot be altered, a separate class iterator is a good choice. This allows for the creation of a new class specifically designed to iterate over the ADT's elements without modifying its implementation. This approach ensures that the original ADT remains unchanged while still providing the functionality of iteration.

Submit
16. If you use quadratic probing for collision resolution, it is recommended that the hash table be

Explanation

When using quadratic probing for collision resolution in a hash table, it is recommended to keep the hash table less than half full. This is because quadratic probing can lead to clustering, where consecutive collisions occur in close proximity to each other. If the table is too full, the likelihood of clustering increases, which can negatively impact the performance of the hash table. By keeping the table less than half full, it allows for a better distribution of the elements and reduces the chances of clustering.

Submit
17. Given a table size of 19 the hash function h(k) = k % table size, what index does the entry 24 map to?

Explanation

The given hash function uses the modulo operator to calculate the index. In this case, the entry 24 will be divided by the table size (19) and the remainder will be taken. The remainder of 24 divided by 19 is 5. Therefore, the entry 24 maps to index 5 in the table.

Submit
18. Given the following array, how many comparisons to an array entry are performed to search for the number13 if you use the binary search algorithm?

Explanation

In binary search, the algorithm compares the target value with the middle element of the array. If the target value is smaller, it continues the search on the left half of the array; if it is larger, it continues on the right half. In this case, the target value is 13. The algorithm compares it with the middle element, which is 6. Since 13 is greater than 6, the algorithm continues the search on the right half. There is only one comparison made in this process, which is comparing 13 with 6. Therefore, the answer is 1.

Submit
19. In the ListIteratorForArrayList class, the remove method throws an IllegalStateExeption when

Explanation

The remove method in the ListIteratorForArrayList class throws an IllegalStateException when any of the following conditions are met: the next method was not called just before it, the previous method was not called just before it, or remove has been called since the last call to next or previous. This means that if any of these conditions are true, calling the remove method will result in an IllegalStateException being thrown. Therefore, the correct answer is "all of the above".

Submit
View My Results

Quiz Review Timeline (Updated): Mar 20, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 20, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • May 14, 2017
    Quiz Created by
    Viet Ho
Cancel
  • All
    All (19)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
A tree in which each node may have at most two children is called a(n)...
Assume you have an array of unsorted items that allows duplicate...
In the IteratorForLinkedList class, the hasNext method determines...
Writing "? super T" where T defines a generic type means
Which method is declared to be protected in the LinkedChainBase class?
The constructor in the SeparateIterator class
To prevent a subclass from overriding protected methods, we declare...
Classes that implement the Comparable interface must define
A node in a binary tree is an object that references a data object and
In a binary tree, if both the left and right child of a node are null
A node with no children is called a(n) _____.
What does the hasNext method return when the list is empty?
Hashing is a good technique for implementing a dictionary when _____...
Nodes that are children of the same parent node are called _____.
A separate class iterator is a good choice when
If you use quadratic probing for collision resolution, it is...
Given a table size of 19 the hash function h(k) = k % table size, what...
Given the following array, how many comparisons to an array entry are...
In the ListIteratorForArrayList class, the remove method throws an...
Alert!

Advertisement