

Java Programming Test Bank
Course Introduction
Java Programming is an introductory course designed to equip students with the foundational skills necessary to develop software applications using the Java programming language. The course covers essential concepts such as object-oriented programming, control structures, data types, exception handling, and the use of standard Java libraries. Through a combination of lectures, hands-on labs, and project work, students will learn how to design, implement, and debug Java applications. By the end of the course, students will have gained practical experience in problem-solving with Java and be prepared to undertake more advanced programming challenges.
Recommended Textbook
Data Abstraction and Problem Solving with Java Walls and Mirrors 3rd Edition by Janet Prichard
Available Study Resources on Quizplus
15 Chapters
870 Verified Questions
870 Flashcards
Source URL: https://quizplus.com/study-set/2590 Page 2


Chapter 1: Review of Java Fundamentals
Available Study Resources on Quizplus for this Chatper
60 Verified Questions
60 Flashcards
Source URL: https://quizplus.com/quiz/51576
Sample Questions
Q1) If d is a double and i is an int,then the assignment statement d = i;is legal in Java.
A)True
B)False
Answer: True
Q2) Which of the following is an example of a wrapper class?
A)Double
B)int
C)String
D)System
Answer: A
Q3) Suppose x and y are int variables.Write a statement that declares the boolean variable between,and sets this variable equal to true if the value of y is between 0 and x,inclusive,and equal to false otherwise.(Assume that you don't know if x is positive or negative. )
Answer: boolean between = (x >= y && y >= 0)|| (0 >= y && y >= x);
Q4) What is wrong with this Java statement? int num = new int(5);
Answer: int is a primitive type in Java,not a class.We can immediately assign it the value of 5;there is no constructor to call,and no need to dynamically allocate memory.
To view all questions and flashcards with answers, click on the resource link above.
Page 3

Chapter 2: Principles of Programming and Software Engineering
Available Study Resources on Quizplus for this Chatper
60 Verified Questions
60 Flashcards
Source URL: https://quizplus.com/quiz/51577
Sample Questions
Q1) A(n)______ is a step-by-step specification of a method to solve a problem within a finite amount of time.
A)prototype
B)module
C)solution
D)algorithm
Answer: D
Q2) List the information provided in a method's precondition.
Answer: The information provided in a method's precondition includes the method's formal parameters,any class named constants that the method uses,and any assumptions that the method makes.
Q3) The specifications of a module indicate how that module should be implemented.
A)True
B)False
Answer: False
Q4) What is a loop invariant?
Answer: A loop invariant is a condition that is true before and after each execution of an algorithm's loop.
Page 4
To view all questions and flashcards with answers, click on the resource link above.

Chapter 3: Recursion: the Mirrors
Available Study Resources on Quizplus for this Chatper
60 Verified Questions
60 Flashcards
Source URL: https://quizplus.com/quiz/51578
Sample Questions
Q1) When is the base case value == anArray[mid] (where mid is the midpoint of the array)reached in a recursive binary search algorithm?
Answer: This base case is reached when the value being searched for is in the original array.
Q2) The binary search algorithm can be applied to an unsorted array.
A)True
B)False
Answer: False
Q3) The base case for a recursive definition of the factorial of n is ______.
A)factorial (-1)
B)factorial (0)
C)factorial (1)
D)factorial (n - 1)
Answer: B
Q4) In the box trace,each box roughly corresponds to a(n)______.
A)recursive relation
B)activation record
C)base case
D)pivot item
Answer: B
To view all questions and flashcards with answers, click on the resource link above. Page 5

Chapter 4: Data Abstraction: The Walls
Available Study Resources on Quizplus for this Chatper
60 Verified Questions
60 Flashcards
Source URL: https://quizplus.com/quiz/51579
Sample Questions
Q1) What does it mean for a class to "implement an interface" ?
Q2) What are exceptions used for?
Q3) What is procedural abstraction?
Q4) What is the difference between the physical size and the logical size of an array?
Q5) What is an axiom?
Q6) Do all Java source files define classes? Explain.
Q7) An ADT's ______ govern(s)what its operations are and what they do.
A)specifications
B)implementation
C)documentation
D)data structure
Q8) What are some of the benefits of modularity?
Q9) A(n)______ is a class that inherits the members of another class.
A)base class
B)superclass
C)abstract class
D)subclass
Q10) What is information hiding?
Q11) When is a compiler-generated default constructor created? Page 6
To view all questions and flashcards with answers, click on the resource link above.
Page 7

Chapter 5: Linked Lists
Available Study Resources on Quizplus for this Chatper
60 Verified Questions
60 Flashcards
Source URL: https://quizplus.com/quiz/51580
Sample Questions
Q1) When you declare a variable that refers to an object of a given class,you are creating a(n)______ to the object.
A)interface
B)reference
C)method
D)ADT
Q2) _______ is a process that transforms an object into a stream of bytes that can be saved to and restored from a file.
A)Information hiding
B)Object serialization
C)Encapsulation
D)Inheritance
Q3) What is the difference between a linear linked list and a circular linked list?
Q4) Write the code fragment to delete the node that the reference variable curr references in a circular doubly linked list?
Q5) Each node in a linear linked list references both its predecessor and its successor.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 8
Chapter 6: Problem Solving With Abstract Data Types
Available Study Resources on Quizplus for this Chatper
60 Verified Questions
60 Flashcards
Source URL: https://quizplus.com/quiz/51581
Sample Questions
Q1) The following string is a valid prefix expression: + * a b c d
A)True
B)False
Q2) Which of the following is the prefix form of the infix expression: (8 + 6)/ (16 - 4)?
A)+ 8 6 / - 16 4
B)/ 8 6 + - 16 4
C)/ + ?- 8 6 16 4
D)/ + 8 6 - 16 4
Q3) The correct grammar for the following language L: L = {w: w is of the form S<sup>n</sup>D<sup>n</sup> for some n 0} Is ______.
A)<legal-word> = S | <legal-word> | D
B)<legal-word> = empty string | S | <legal-word> | D
C)<legal-word> = S <legal-word> D
D)<legal-word> = empty string | S <legal-word> D
Q4) What is the main benefit of using a grammar that is recursive?
Q5) What is an infix expression?
Q6) What is a closed-form formula?

Page 9
To view all questions and flashcards with answers, click on the resource link above.

Chapter 7: Stacks
Available Study Resources on Quizplus for this Chatper
60 Verified Questions
60 Flashcards
Source URL: https://quizplus.com/quiz/51582
Sample Questions
Q1) Which of the following methods is NOT called by the nonrecursive stack version of the isPath method?
A)insertAdjacent
B)unvisitAll
C)markVisited
D)getNextCity
Q2) Describe an example of a game in which the logic of the game makes use of a stack.
Q3) In the StackInterface class,the pop method returns an item that is an instance of ______.
A)Integer
B)Double
C)String D)Object
Q4) The ______ method of the ADT stack retrieves and then removes the top of the stack.
A)createStack
B)push C)pop D)peek
To view all questions and flashcards with answers, click on the resource link above. Page 10

Chapter 8: Queues
Available Study Resources on Quizplus for this Chatper
60 Verified Questions
60 Flashcards
Source URL: https://quizplus.com/quiz/51583
Sample Questions
Q1) The first item to be added to a queue is the first item to be removed from the queue.
A)True
B)False
Q2) The pop operation of the ADT stack is similar to the ______ operation of the ADT queue.
A)isEmpty
B)enqueue
C)dequeue
D)peek
Q3) What is an event-driven simulation?
Q4) What is a deque?
Q5) Which of the following operations leaves a queue unchanged?
A)enqueue
B)dequeue
C)dequeueAll
D)peek
Q6) What is the action performed by the peek operation?
Q7) If you wanted to write a program to simulate queues in front a bank teller,on what basis would you decide on a maximum size of your queue?
To view all questions and flashcards with answers, click on the resource link above. Page 11
Chapter 9: Advanced Java Topics
Available Study Resources on Quizplus for this Chatper
60 Verified Questions
60 Flashcards
Source URL: https://quizplus.com/quiz/51584
Sample Questions
Q1) In a class within a package,the keyword ______ must appear in front of the class keyword to make the class available to clients of the package.
A)open
B)public
C)protected
D)package
Q2) What is meant by object type compatibility?
Q3) Which of the following is true about an abstract class?
A)it can be instantiated
B)it can contain zero or more abstract methods
C)it cannot be inherited by other classes
D)it cannot contain data fields
Q4) ______ is the ability of a class to derive properties from a previously defined class.
A)Encapsulation
B)Simulation
C)Inheritance
D)Polymorphism
Q5) What does the reference super represent?
Q6) What is a subinterface?

Page 12
To view all questions and flashcards with answers, click on the resource link above.

Chapter 10: Algorithm Efficiency and Sorting
Available Study Resources on Quizplus for this Chatper
60 Verified Questions
60 Flashcards
Source URL: https://quizplus.com/quiz/51585
Sample Questions
Q1) List the three factors which can cloud the comparison of algorithms performed by implementing the algorithms in Java and running the programs.
Q2) How does the quicksort partition an array?
Q3) What is determined by worst-case analysis?
Q4) Algorithm efficiency is typically a concern for ______. A)small problems only B)large problems only C)medium sized problems only D)problems of all sizes
Q5) What does the area analysis of algorithms focus on?
Q6) An algorithm's time requirements can be derived as a function of the problem size. A)True B)False
Q7) Consider the following nested loop.What is the order of the algorithm? for (int i = 0;i < n;++i) for (j = 1;j < n;j *= 2)
Q8) What is determined by average-case analysis?
Q9) What is measured by an algorithm's growth rate?
To view all questions and flashcards with answers, click on the resource link above. Page 13

Chapter 11: Trees
Available Study Resources on Quizplus for this Chatper
60 Verified Questions
60 Flashcards
Source URL: https://quizplus.com/quiz/51586
Sample Questions
Q1) In a ______ of height h,all nodes that are at a level less than h have two children each.
A)general tree
B)binary tree
C)full binary tree
D)complete binary tree
Q2) The node that is directly above node n in a tree is called the ______ of node n.
A)root
B)leaf
C)parent
D)child
Q3) In an array based representation of a complete binary tree,which of the following represents the left child of node tree[i]?
A)tree[i+2]
B)tree[i-2]
C)tree[2*i+1]
D)tree[2*i+2]
Q4) What is a search key?
Q5) In an array-based representation of a binary tree,what kind of information is stored in a free list?
14
To view all questions and flashcards with answers, click on the resource link above.

Chapter 12: Tables and Priority Queues
Available Study Resources on Quizplus for this Chatper
60 Verified Questions
60 Flashcards
Source URL: https://quizplus.com/quiz/51587
Sample Questions
Q1) In a linear implementation of the priority queue based on a linked list,the item with the highest priority value is located ______.
A)at the beginning of the linked list
B)at the end of the linked list
C)in the middle of the linked list
D)at a random location in the linked list
Q2) When implementing an ADT such as a table,one design question is how often each ADT operation is to be performed.Why do we ask ourselves this question?
Q3) In an unsorted array-based implementation of the ADT table,the retrieval operation is ______.
A)O(1)
B)O(n)
C)O(n²)
D)O(log n)
Q4) Heapsort is a sorting algorithm that uses the heap data structure.Discuss how we can use a binary search tree to sort a list of values.Why would such an algorithm not perform as efficiently as heapsort?
Q5) What are the four categories of linear implementations of tables?
To view all questions and flashcards with answers, click on the resource link above. Page 15

Chapter 13: Advanced Implementations of Tables
Available Study Resources on Quizplus for this Chatper
60 Verified Questions
60 Flashcards
Source URL: https://quizplus.com/quiz/51588
Sample Questions
Q1) A balanced binary search tree would have the maximum height possible for the tree.
A)True
B)False
Q2) A 2-3 tree of height h always has at least ______ nodes.
A)h²
B)h² - 2
C)2h
D)2h - 1
Q3) What makes 2-3-4 trees more attractive than 2-3 trees?
Q4) In a 2-3 tree,how is the search key of a 3-node related to the search keys in the left subtree,the middle subtree,and the right subtree of the 3-node?
Q5) In a 2-3-4 tree,when is a 4-node split during an insertion operation?
Q6) A 2-3 tree is a binary tree.
A)True
B)False
Q7) What are the two types of rotations possible in an AVL tree?
Q8) What is the advantage of using a variation of a binary search tree,such as a 2-3 tree or a 2-3-4 tree,instead of a binary search tree?
To view all questions and flashcards with answers, click on the resource link above. Page 16
Chapter 14: Graphs
Available Study Resources on Quizplus for this Chatper
60 Verified Questions
60 Flashcards
Source URL: https://quizplus.com/quiz/51589
Sample Questions
Q1) What are two differences between a directed graph and an undirected graph?
Q2) A ______ is an undirected connected graph without cycles.
A)tree
B)multigraph
C)digraph
D)connected component
Q3) Which of the following is true about a simple cycle?
A)it can pass through a vertex more than once
B)it can not pass through a vertex more than once
C)it begins at one vertex and ends at another
D)it passes through only one vertex
Q4) A connected graph has an edge between every pair of vertices.
A)True
B)False
Q5) In a digraph,there can be only one edge between a pair of vertices. A)True
B)False
Q6) A graph's edges cannot begin and end at the same vertex.
A)True
B)False

Page 17
To view all questions and flashcards with answers, click on the resource link above.

Chapter 15: External Methods
Available Study Resources on Quizplus for this Chatper
30 Verified Questions
30 Flashcards
Source URL: https://quizplus.com/quiz/51590
Sample Questions
Q1) What type of tree is best used for indexing external data?
A)B-tree
B)binary search tree
C)2-3-4 tree
D)AVL tree
Q2) In the external mergesort algorithm,how many buffers are needed to merge runs?
A)one
B)two
C)three
D)four
Q3) What is the advantage of using a B-tree instead of a 2-3 tree for indexing external data?
Q4) Which of the following information is not necessary in order to perform (i.e.invoke)a readBlock operation?
A)buffer
B)file
C)block number
D)the data contained in the block
Q5) Name two advantages to storing a data structure in external storage.
Q6) What is the maximum number of nodes in a B tree of height 3 and degree 10?
To view all questions and flashcards with answers, click on the resource link above. Page 18