

Data Structures and Algorithms
Exam Answer Key

Course Introduction
Data Structures and Algorithms is a foundational course that explores the essential building blocks of computer science, focusing on the design, analysis, and implementation of efficient methods for organizing and manipulating data. Students learn about a variety of data structures such as arrays, linked lists, stacks, queues, trees, and graphs, as well as algorithmic techniques including sorting, searching, recursion, and dynamic programming. The course emphasizes solving computational problems efficiently in terms of time and space complexity, providing students with the skills necessary to optimize software performance and tackle real-world challenges in computing.
Recommended Textbook
Java Programming 7th Edition by Joyce Farrell
Available Study Resources on Quizplus
17 Chapters
1208 Verified Questions
1208 Flashcards
Source URL: https://quizplus.com/study-set/1207 Page 2

Chapter 1: Creating Java Programs
Available Study Resources on Quizplus for this Chatper
68 Verified Questions
68 Flashcards
Source URL: https://quizplus.com/quiz/23890
Sample Questions
Q1) Provide examples of logic errors. How do programmers minimize logic errors in their code?
Answer: Examples of logic errors include multiplying two values when you meant to add, printing one copy of a report when you meant to print five, or forgetting to produce a requested count of the number of times an event has occurred. Errors of this type must be detected by carefully examining the program output. It is the responsibility of the program author to test programs and find any logic errors. Good programming practice stresses programming structure and development that helps minimize errors.
Q2) ____ are also called modules, methods, functions, and subroutines. Java programmers most frequently use the term "method."
A) Procedures
B) Calls
C) Classes
D) Applications
Answer: A
Q3) You use an import statement when you want to access a built-in Java class that is contained in a group of classes called a(n) ____________________.
Answer: package
To view all questions and flashcards with answers, click on the resource link above.
3

Chapter 2: Using Data
Available Study Resources on Quizplus for this Chatper
74 Verified Questions
74 Flashcards
Source URL: https://quizplus.com/quiz/23891
Sample Questions
Q1) You use ____ operators to perform calculations with values in your programs.
A) calculation
B) arithmetic
C) integer
D) precedence
Answer: B
Q2) Why is the following relational operator expression invalid? How could you rewrite the statement so that it is valid?
boolean isGradePassing = (grade => 70);
Answer: In this statement, the order of the operator symbols is reversed. It is illegal to use =<, =>, and =!.
The statement could be modified as follows: boolean isGradePassing = (grade >= 70);
Q3) A(n) ____________________ number contains decimal positions.
Answer: floating-point float double
Q4) Write the statement to declare an uninitialized integer value for salesAmt.
Answer: int salesAmt; The statement must end with a semicolon.
Page 4
To view all questions and flashcards with answers, click on the resource link above.

Chapter 3: Using Methods, Classes, and Objects
Available Study Resources on Quizplus for this Chatper
68 Verified Questions
68 Flashcards
Source URL: https://quizplus.com/quiz/23892
Sample Questions
Q1) Data items you use in a call to a method are called ____.
A) arguments
B) instance variables
C) method declarations
D) headers
Answer: A
Q2) The interface is the part of a method that the method's client does not see.
A)True
B)False
Answer: False
Q3) For ease in locating class methods, many programmers store them in ____ order.
A) chronological
B) type
C) alphabetical
D) numeric
Answer: C
Q4) Any class can contain an unlimited number of methods.
A)True
B)False
Answer: True
To view all questions and flashcards with answers, click on the resource link above. Page 5

Chapter 4: More Object Concepts
Available Study Resources on Quizplus for this Chatper
67 Verified Questions
67 Flashcards
Source URL: https://quizplus.com/quiz/23893
Sample Questions
Q1) Using an example, explain how nested blocks are created.
Q2) You can use the keyword final with methods or classes.
A)True
B)False
Q3) No object associated with them
A)optional classes
B)instance variables
C)comes into scope
D)class methods
E)overloading
F)Math class
G)redeclaring a variable
H)GregorianCalendar
I)constant
Q4) A locally declared variable always ____ another variable with the same name elsewhere in the class.
A) creates
B) masks
C) deletes
D) uses
To view all questions and flashcards with answers, click on the resource link above. Page 6

Chapter 5: Making Decisions
Available Study Resources on Quizplus for this Chatper
70 Verified Questions
70 Flashcards
Source URL: https://quizplus.com/quiz/23894
Sample Questions
Q1) A ____ checks a value, and based on the result performs one of two actions.
A) short-circuit structure
B) sequence structure
C) decision structure
D) block structure
Q2) An alternative to using a Boolean expression, such as someVariable == 10, is to store the Boolean expression's value in a Boolean variable.
A)True
B)False
Q3) When you block statements, you must remember that any ____ you declare within a block is local to that block.
A) method
B) expression
C) variable
D) decision
Q4) Within an if or an else statement, how can you code as many dependent if statements as you need?
Q5) List and explain the keywords used with the switch statement.
Q6) Why would a programmer need to use a range check? Give an example.
To view all questions and flashcards with answers, click on the resource link above. Page 7

Chapter 6: Looping
Available Study Resources on Quizplus for this Chatper
72 Verified Questions
72 Flashcards
Source URL: https://quizplus.com/quiz/23895
Sample Questions
Q1) Within parentheses are three sections separated by exactly two semicolons
A)prefix ++
B)block
C)definite loop
D)loop control variable
E)binary operators
F)loop fusion
G)decrementing
H)for loop
I)sleep() method
Q2) A statement that will alter the value of the loop control variable is included in the body of a loop.
A)True
B)False
Q3) In order to improve loop performance, it's important to make sure the loop does not include unnecessary operations or statements.
A)True
B)False
Q4) The ____________________ loop is the posttest loop used in Java.
Q5) Why would a programmer use curly braces in the body of a do while loop?
To view all questions and flashcards with answers, click on the resource link above. Page 8

Chapter 7: Characters, Strings, and the Stringbuilder
Available Study Resources on Quizplus for this Chatper
73 Verified Questions
73 Flashcards
Source URL: https://quizplus.com/quiz/23896
Sample Questions
Q1) How can you change the length of a String in a StringBuilder object?
Q2) Which of the following correctly declares and initializes a String object?
A) new String = Hello
B) String greeting == "Hello";
C) String greeting = "Hello";
D) String new = "Hello"
Q3) The creators of Java chose ____ characters as the "extra" length for a StringBuilder object.
A) 12
B) 16
C) 36
D) 48
Q4) Explain what is needed to declare a String variable and provide an example.
Q5) When working with Strings, it is necessary to explicitly set a String to null.
A)True
B)False
Q6) StringBuilder greeting = new StringBuilder("Day 1");
Using the above StringBuilder, create a setCharAt() method that will change the "1" to a "2" in the String "Day 1". Explain how the setCharAt() method operates.
Page 9
To view all questions and flashcards with answers, click on the resource link above.

Chapter 8: Arrays
Available Study Resources on Quizplus for this Chatper
74 Verified Questions
74 Flashcards
Source URL: https://quizplus.com/quiz/23897
Sample Questions
Q1) Since an array name is a reference, you are able to use the = operator for assigning and the == operator for comparisons.
A)True
B)False
Q2) How can you use the enhanced for loop?
Q3) Hold memory addresses where values are stored
A)array variable
B)reference type
C)elements
D)int
E)Java object names
F)length
G)foreach loop
H)reference types
I)return
Q4) What is a subscript and how are the array's elements numbered?
Q5) int[] sixNumbers = {1, 2, 3, 4};
The above code creates an array named sixNumbers. Describe how array sizes are determined when using an initialization list and how memory is assigned.
To view all questions and flashcards with answers, click on the resource link above. Page 10

Chapter 9: Advanced Array Concepts
Available Study Resources on Quizplus for this Chatper
74 Verified Questions
74 Flashcards
Source URL: https://quizplus.com/quiz/23898
Sample Questions
Q1) When you pass a two-dimensional array to a method, you pass the array name just as you do with a one-dimensional array.
A)True
B)False
Q2) How would you create an array named someNumbers that holds three rows and four columns?
A) int[][] someNumbers = new int[4][3]
B) int[][] someNumbers = new int[3][4]
C) int[] someNumbers = new int[3][4]
D) double[][] someNumbers = new int[3][4]
Q3) How can you sort arrays of objects?
Q4) int[] myVals = {2, 4, 6, 8} Using the above four-element array, what is the value of myVals[1]?
A) 2
B) 4
C) 6
D) 8
Q5) The simplest possible sort involves two values that are out of order.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 11

Chapter 10: Introduction to Inheritance
Available Study Resources on Quizplus for this Chatper
70 Verified Questions
70 Flashcards
Source URL: https://quizplus.com/quiz/23899
Sample Questions
Q1) In most Java classes, the keyword private precedes each data field, and the keyword ____________________ precedes each method.
Q2) You use the keyword ____ to achieve inheritance in Java. A) inherit B) extends C) super D) public
Q3) Within a subclass, you can think of the keyword ____ as the opposite of super. A) sub B) this C) protected D) not
Q4) When a protected data field or method is created, it can be used within its own class or in any classes extended from that class; but it cannot be used by outside classes. A)True B)False
Q5) What are virtual method calls?
Q6) When you instantiate an object that is a member of a subclass, how many constructors are called?
Page 12
To view all questions and flashcards with answers, click on the resource link above.

Chapter 11: Advanced Inheritance Concepts
Available Study Resources on Quizplus for this Chatper
70 Verified Questions
70 Flashcards
Source URL: https://quizplus.com/quiz/23900
Sample Questions
Q1) public interface FindTheError
{ void firstMethod(int anIntNum)
{ System.out.println("Did you find the error?");
}
}
What is the problem with the above interface? How would you correct the interface?
Q2) A(n) ____ class is one from which you cannot create any concrete objects, but from which you can inherit.
A) abstract
B) inheritance
C) parent
D) final
Q3) The capability to inherit from more than one class is called ____.
A) multiple inheritance
B) collision
C) polyinheritance
D) dynamic method binding
To view all questions and flashcards with answers, click on the resource link above.
Page 13

Chapter 12: Exception Handling
Available Study Resources on Quizplus for this Chatper
65 Verified Questions
65 Flashcards
Source URL: https://quizplus.com/quiz/23901
Sample Questions
Q1) ____ represents the degree to which a system is resilient to stress, maintaining correct functioning.
A) Endurance
B) Robustness
C) Fault-tolerant
D) Strength
Q2) What is unreachable code and how might using multiple catch blocks cause this? Provide an example.
Q3) If you want to ensure that a user enters numeric data, you should use ____ techniques that provide the means for your program to recover from the mistake.
A) error-handling
B) looping
C) exception-handling
D) decision
Q4) Some programmers refer to a catch block as a catch ____.
A) method
B) phrase
C) statement
D) clause
To view all questions and flashcards with answers, click on the resource link above. Page 14

Chapter 13: File Input and Output
Available Study Resources on Quizplus for this Chatper
74 Verified Questions
74 Flashcards
Source URL: https://quizplus.com/quiz/23902
Sample Questions
Q1) import java.util.Scanner; import java.nio.file.*; public class PathDemo2
{ public static void main(String[] args)
{ String name; Scanner keyboard = new Scanner(System.in); System.out.print("Enter a file name >> "); name = keyboard.nextLine(); Path inputPath = Paths.get(name);
System.out.println("Full path is " + fullPath.toString());
} }
Using the above code, complete the shaded line with a statement that creates an absolute path by assigning the file to the current directory.
Q2) How can you categorize files by the way they store data?
Q3) ____________________ is an abstract class that contains methods for performing output.
To view all questions and flashcards with answers, click on the resource link above. Page 15

Chapter 14: Introduction to Swing Components
Available Study Resources on Quizplus for this Chatper
74 Verified Questions
74 Flashcards
Source URL: https://quizplus.com/quiz/23903
Sample Questions
Q1) When you create a(n) ____, you can group several components, such as JCheckBoxes, so a user can select only one at a time.
A) CheckGroup
B) ButtonGroup
C) OptionBox
D) OptionGroup
Q2) import javax.swing.*; public class JFrame1
{ public static void main(String[] args)
{
JFrame aFrame = new JFrame("First frame"); aFrame.setSize(300, 125); aFrame.setVisible(true);
}
}
The three shaded statements in the main() method above are important. Explain the purpose of each statement and why they are necessary for creating a JFrame.
Q3) Provide an example of an event-driven program.
To view all questions and flashcards with answers, click on the resource link above.
Page 16

Chapter 15: Advanced Gui Topics
Available Study Resources on Quizplus for this Chatper
69 Verified Questions
69 Flashcards
Source URL: https://quizplus.com/quiz/23904
Sample Questions
Q1) Describe the difference between an ActionEvent and a MouseEvent.
Q2) Each JMenu can contain options, called JMenuItems, or can contain submenus that are ____.
A) JMenuBars
B) JMenuChildren
C) JSubMenus
D) JMenus
Q3) When components in a Swing UI require more display area than they have been allocated, you can use a ____ container to hold the components and allow the user to display the components using scroll bars.
A) JScrollingPane
B) ScrollLayout
C) JPanel
D) JScrollPane
Q4) The wildcard in the import java.awt.* statement imports all types in the java.awt package, including java.awt.Color and java.awt.Font.
A)True
B)False
Q5) Describe the two CardLayout constructors.
To view all questions and flashcards with answers, click on the resource link above. Page 17
Chapter 16: Graphics
Available Study Resources on Quizplus for this Chatper
74 Verified Questions
74 Flashcards
Source URL: https://quizplus.com/quiz/23905
Sample Questions
Q1) Write the statement to create a Rectangle2D.Float object named myRect at 20, 20 with a width of 80 and height of 50.
Q2) In the drawPolygon() method, what are the three arguments and what values do they represent?
Q3) The ____ method provides information about the system in use.
A) getSystemInfo()
B) getDefaultToolkit()
C) getDefaultControlPanel()
D) getToolkit()
Q4) You can use the ____ method to copy any rectangular area to a new location.
A) copyRect()
B) copyArea()
C) copyGraphics()
D) addPoint()
Q5) You can instruct a Graphics object to use a font by inserting the font as the argument in a ____ method.
A) setColor()
B) drawString()
C) setCharacters()
D) setFont()

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

Chapter 17: Applets, Images, and Sound
Available Study Resources on Quizplus for this Chatper
72 Verified Questions
72 Flashcards
Source URL: https://quizplus.com/quiz/23906
Sample Questions
Q1) The ___________________ method is always called after the init() and start() methods execute.
Q2) A simple language used to create Web pages for the Internet
A)current version of HTML
B)init()
C)start()
D)HTML
E)Applet Viewer
F)tags
G)multimedia
H)applet
I)play()
Q3) You can run an applet in a ____.
A) main() method
B) Java application
C) Web server
D) Web browser
Q4) What are the two forms of the play() method?
Q5) Describe the stop() method.
Q6) What are the methods of the applet life cycle?
To view all questions and flashcards with answers, click on the resource link above. Page 19