

Java Programming Exam Preparation Guide
Course Introduction
Java Programming is an introductory course designed to teach students the fundamentals of programming using the Java language. The course covers core programming concepts such as variables, data types, control structures, functions, and object-oriented programming principles including classes, inheritance, and polymorphism. Students will also gain practical experience in exception handling, file input/output, and graphical user interface (GUI) development. Through lectures, coding exercises, and projects, learners will develop the skills required to design, implement, and debug Java applications, preparing them for more advanced studies in computer science or software development.
Recommended Textbook
Java Foundations 3rd Edition by John Lewis
Available Study Resources on Quizplus
16 Chapters
639 Verified Questions
639 Flashcards
Source URL: https://quizplus.com/study-set/3997

Page 2

Chapter 1: Introduction
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/80262
Sample Questions
Q1) What are some advantages to writing programs in a high-level language instead of machine code?
Answer: Programs written in a high-level language are more easily readable by humans and, therefore, they can be debugged and maintained easier than programs written in machine code. In addition, high-level languages support more natural problem-solving approaches such as object-oriented programming, whereas machine languages typically do not.
Q2) Which of the following will is considered a logical error?
A) forgetting a semicolon at the end of a programming statement
B) typing a curly bracket when you should have typed a parenthesis
C) multiplying two numbers when you meant to add them
D) dividing by zero
E) misspelling an identifier
Answer: C
Q3) Java is case-sensitive.
A)True
B)False
Answer: True
Q4) Write an application that prints the first few lines of a song (your choice).
Answer: 11edd9cc_5a45_7376_84e8_afca069acf96_TB2841_00
To view all questions and flashcards with answers, click on the resource link above. Page 3

Chapter 2: Data and Expressions
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/80257
Sample Questions
Q1) In Java, all floating point literals are assumed to be of type float.
A)True
B)False
Answer: False
Q2) Explain why it might not be safe for a programmer to use a narrowing conversion.
Answer: A narrowing conversion might not be safe because it can result in information loss. This is because in a narrowing conversion a programmer is changing a piece of data from a data type that can hold more information into a data type that can hold less information.
Q3) The print and the println methods are identical and can be used interchangeably.
A)True
B)False
Answer: False
Q4) Information is most likely to be lost in what kind of data conversion?
A) A widening conversion
B) A narrowing conversion
C) promotion
D) assignment conversion
E) no information will be lost in any of the conversions listed above
Answer: B
To view all questions and flashcards with answers, click on the resource link above. Page 4

Chapter 3: Using Classes and Objects
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/80255
Sample Questions
Q1) When an object variable is declared but it is not assigned a value, it is called a
A) null reference
B) empty reference
C) void reference
D) zero reference
E) static reference
Answer: A
Q2) Write a short program that allows the user to input a positive integer and then outputs a randomly generated integer between 1 and the input number.
Answer: 11edd9d1_cc58_b0e2_84e8_63d1af102de8_TB2841_00
Q3) When there are no references to an object, the object is marked as garbage and is automatically removed from memory using Java's automatic garbage collection feature.
A)True
B)False
Answer: True
Q4) Write a single line that creates a wrapper for an int variable num. Answer: Integer numWrapper = new Integer(num);
To view all questions and flashcards with answers, click on the resource link above. Page 5
Chapter 4: Conditionals and Loops
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/80254
Sample Questions
Q1) Which of the following for loop headers will cause the body of the loop to be executed 10 times?
A) for(int i = 0; i <= 10; i++)
B) for(int i = 1; i < 10; i++)
C) for(int i = 1; i <= 11; i++)
D) for(int i = 0; i < 10; i++)
E) none of these for loops will execute the loop body 10 times
Q2) Which of the following logical operators has the highest precedence?
A) !
B) && C) ||
D) <
E) >
Q3) A Scanner object can use delimiters other than a space. A)True
B)False
Q4) Write a for loop to print the even numbers from 1 to 100 (inclusive).
Q5) In Java, a boolean expression is limited to having exactly 2 logical operators. A)True
B)False

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

Chapter 5: Writing Classes
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/80253
Sample Questions
Q1) If a service is so complex that it cannot be reasonably be implemented using one method, it is often helpful to decompose it to make use of ________________ support methods.
A) static
B) aggregate
C) private
D) public
E) final
Q2) When applied to instance variables, the ________________ visibility modifier enforces encapsulation.
A) static
B) final
C) public
D) private
E) none of the above
Q3) Write a method called countSpaces that takes in a String as a parameter and returns an integer that represents the number of space characters (' ') contained in the string, false otherwise..
Q4) Explain the difference between actual parameters and formal parameters.
Q5) What is the difference between an object and a class?
To view all questions and flashcards with answers, click on the resource link above. Page 7

Chapter 6: Graphical User Interfaces
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/80252
Sample Questions
Q1) A dialog box allows the user to select one of several options from a "drop down" menu.
A)True
B)False
Q2) A mnemonic is a short line of text that will appear when the cursor is rested momentarily on top of the component.
A)True
B)False
Q3) Describe the areas of a border layout.
Q4) The ability of the user should be ignored when designing GUIs. In other words, GUIs should be designed with the most unskilled user in mind.
A)True
B)False
Q5) GUI is an acronym for _______________________.
A) graphical UML interface
B) graphical UML implementation
C) graphical user implementation
D) graphical user interface
E) none of the above
To view all questions and flashcards with answers, click on the resource link above. Page 8

Chapter 7: Arrays
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/80251
Sample Questions
Q1) If a program attempts to access an element outside of the range of the array indexes, a run-time error will occur.
A)True
B)False
Q2) Write a method that takes in at least one integer and returns the largest of all integer parameters sent in.
Q3) Which of the following are true about two-dimensional arrays?
A) Two-dimensional integer arrays cannot be initialized via an initializer list.
B) Two-dimensional arrays can only store up to 10 elements per array (or per row).
C) Two-dimensional arrays are not accessible using for loops.
D) Two-dimensional arrays cannot hold objects.
E) None of the above are true.
Q4) It is possible to send in data to a Java program via the command-line.
A)True
B)False
Q5) Write a short program that accepts an arbitrary number of command line arguments, and prints out those containing the character 'z'.
Q6) Explain how arrays are passed to methods as parameters.
To view all questions and flashcards with answers, click on the resource link above. Page 9

Chapter 8: Inheritance
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/80250
Sample Questions
Q1) It makes sense to declare most abstract methods as final.
A)True
B)False
Q2) In order for derived classed to have access to encapsulated data members and methods of superclasses, the data members and methods should be declared using the ____________________ modifier.
A) private
B) public
C) protected D) final
E) static
Q3) To invoke a parents constructor in a subclass, we use the ______________ method.
A) abstract
B) construct C) parent D) super E) extends
Q4) Draw a hierarchy of Animals. The hierarchy should include the following entities: Animal, Reptile, Mammal, Bear, Human, Iguana, and Dolphin.
Page 10
To view all questions and flashcards with answers, click on the resource link above.

Chapter 9: Polymorphism
Available Study Resources on Quizplus for this Chatper
39 Verified Questions
39 Flashcards
Source URL: https://quizplus.com/quiz/80249
Sample Questions
Q1) An interface cannot declare any instance variables.
A)True
B)False
Q2) Why can't an interface be instantiated?
Q3) If a class implements an interface, it cannot extend another class.
A)True
B)False
Q4) An interface name may be used as a reference type.
A)True
B)False
Q5) A single class may implement multiple interfaces.
A)True
B)False
Q6) The next method of the Iterator interface returns a reference to the next element in a collection and removes it.
A)True
B)False
Q7) How does inheritance relate to polymorphism in Java?
To view all questions and flashcards with answers, click on the resource link above. Page 11
Q8) Write an interface for a CD player. It should have the standard operations (i.e. play, stop, etc) that usual CD players have.
Chapter 11: Recursion
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/80260
Sample Questions
Q1) A method that calls a different method, which then calls the original calling method is a recursive method.
A)True
B)False
Q2) What is recursion?
Q3) All recursive programs ____________________________________ .
A) are more difficult to read than iterative programs.
B) can be implemented iteratively.
C) are easier to read than iterative programs.
D) are shorter than iterative programs.
E) none of the above are true.
Q4) All recursive methods must have a base case.
A)True
B)False
Q5) In a recursive solution, _______________ is(are) always necessary.
A) short, efficient code
B) several variables
C) numerous lines of code
D) a base case
E) none of the above

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

Chapter 10: Exceptions
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/80261
Sample Questions
Q1) An exception will be propagated until it is caught and handled or until it is passed out of the main method.
A)True
B)False
Q2) What is a catch clause?
Q3) Give two examples of methods in the Exception class that can be used to output information about the Exception.
Q4) Every line in a catch block is guaranteed to be executed in all situations.
A)True
B)False
Q5) What is the difference between an exception and an error?
Q6) How does a method throw an exception?
Q7) What is a try block?
Q8) What are the standard I/O streams?
Q9) Attempting to divide by zero will result in an Error being thrown, not an Exception. A)True B)False
Q11) What is exception prorogation, and how does it work in Java? Page 13
Q10) What is the difference between a checked exception and an unchecked exception?
To view all questions and flashcards with answers, click on the resource link above.
Page 14

Chapter 12: Searching and Sorting
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/80259
Sample Questions
Q1) Bubble sort is the most efficient searching algorithm.
A)True
B)False
Q2) ____________________ is the process of arranging a group of items into a defined order.
A) Searching
B) Sorting
C) Selecting
D) Helping
E) none of the above
Q3) In a binary search, _______________________________ .
A) it is assumed that all of the elements are integers.
B) it is assumed that all of the elements are Strings.
C) it is assumed that the search pool is small.
D) it is assumed that the search pool is ordered.
E) it is assumed that the search pool is large.
Q4) To represent constant time complexity we use O(c).
A)True
B)False
Q5) Explain how merge sort works.
To view all questions and flashcards with answers, click on the resource link above. Page 15

Chapter 13: Trees
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/80258
Sample Questions
Q1) What property of the tree does its order specify?
A) maximum height
B) maximum number of leaves
C) maximum number of internal nodes
D) maximum number of edges
E) maximum number of children per node
Q2) Which of the following tree traversals traverses the subtrees from left to right and then visits the root?
A) Preorder
B) Inorder
C) Postorder
D) Level-order
E) none of the above
Q3) How many leaves will be contained in a full binary tree of height 5?
Q4) In a postorder traversal, the root is the last element visited in the tree.
A)True
B)False
Q5) What is the root of a tree?
Q6) What is a disadvantage of implementing a tree as an array using computed links?
Q7) What does it mean for a tree to be balanced?
To view all questions and flashcards with answers, click on the resource link above. Page 16

Chapter 14: Introduction to Collections and Stacks
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/80248
Sample Questions
Q1) Which of the following is not a valid postfix expression?
A) 5 4 +
B) 6 5 4 + -
C) 4 + 5
D) 8 2 + 2 /
E) all of the above are valid postfix expressions
Q2) A queue is the ideal collection to use when ____________________ .
A) implementing a radix sort
B) evaluating a postfix expression
C) evaluating an infix expression
D) implementing a quick sort
E) none of the above
Q3) A queue is a ____________________ data structure.
A) LIFO
B) FIFO
C) link based
D) array based
E) none of the above
Q4) List the five basic operations on a queue.
Q5) What is wrong with the java.util.Stack implementation of a stack?
Page 17
To view all questions and flashcards with answers, click on the resource link above.

Chapter 15: Heaps and Priority Queues
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/80247
Sample Questions
Q1) If a binary search tree becomes unbalanced after an element is added, it is sometimes possible to efficiently rebalance the tree by ___________________ .
A) using left and right rotations
B) selecting a leaf node to use as a new root
C) reconstructing the tree from scratch
D) all of the above
E) it is impossible to rebalance a tree efficiently
Q2) Why is it important to keep a binary search tree balanced?
Q3) Left and right rotations can be used to rebalance an unbalanced binary search tree. A)True B)False
Q4) Describe how to find an element in a binary search tree. You may use English sentences or pseudocode.
Q5) The most efficient binary search trees are balanced. A)True B)False
Q6) What is a heap?
Q7) Explain the process of removing an element from a binary search tree.
To view all questions and flashcards with answers, click on the resource link above. Page 18

Chapter 16: Graphs
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/80256
Sample Questions
Q1) A depth-first traversal of a graph uses which of the following data structures?
A) binary search tree
B) stack
C) queue
D) array
E) none of the above
Q2) A complete graph on n vertices has n(n-1)/2 edges.
A)True
B)False
Q3) A cycle is a path that starts and ends on the same vertex.
A)True
B)False
Q4) An adjacency matrix is one approach to implementing a graph that uses a two-dimensional array.
A)True
B)False
Q5) Can a tree ever have a cycle? Explain.
Q6) What data structure is used to support a depth-first traversal of a graph?
Q7) What is the difference between a directed graph and an undirected graph?
Q8) Is every tree a graph? Is every graph a tree? Explain.
To view all questions and flashcards with answers, click on the resource link above. Page 19