

Programming Fundamentals
Practice Exam
Course Introduction
Programming Fundamentals introduces students to the basic concepts and principles of computer programming. This course covers essential topics such as variables, data types, control structures, functions, arrays, and object-oriented programming. Students will learn how to design, write, debug, and test simple computer programs using a high-level programming language. Emphasis is placed on problem-solving techniques, logical thinking, and understanding the foundational elements that underpin modern software development. By the end of the course, students will have gained the practical skills necessary to pursue more advanced programming topics and applications.
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) Write an application that prints the first few lines of a song (your choice).
Answer: 11edd9cc_5a45_7376_84e8_afca069acf96_TB2841_00
Q2) 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.
Q3) Identifiers can be of any length.
A)True
B)False
Answer: True
Q4) Explain the difference between the syntax of a program and the semantics of a program.
Answer: Syntax rules dictate the form of a program. Semantics dictate the meaning of the program statements. In other words, syntax specifies the actual code of the program, while semantics refers to the meaning that is attached to the code.
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) How are primitive data types and object data types related?
Answer: Object types are more complex data types, and they are generally made up of primitive data types.
Q2) Suppose your numeric grade is calculated using the following formula:
Test 1: 15%
Test 2: 15%
Final Exam: 30%
Homework: 10%
Programming Projects: 30%
Determine a good variable name to represent each of these values. Write a single expression to compute your grade assuming the variables have been declared and each one stores its value as an integer in the range 0 to 100.
Answer: double grade = test1*.15 + test2*.15 + exam*.3 + homework*.1 + projects*.3;
Q3) Write a short program that allows the user to enter the year that they were born (as an integer) and outputs the age that they will be at the end of this year. Declare the current year as a constant.
Answer: 11edd9d0_40e5_cc0f_84e8_112d805f3fa4_TB2841_00
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) Which of the following best describes what happens when an object no longer has any references pointing to it?
A) The object is overwritten the next time the new operator is called.
B) The object is overwritten the next time the new operator is called using the same class.
C) The object is immediately deleted from memory.
D) The object is marked as garbage and its associated memory is freed when the garbage collector runs.
E) The object stays in memory for the remainder of the programs execution.
Answer: D
Q2) When two references point to the same object,
A) a run-time error will occur.
B) a compiler error will occur.
C) the references are called aliases of each other.
D) the object will be marked for garbage collection.
E) the references are called null references.
Answer: C
Q3) 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) Write a short code fragment that uses a while loop to verify that the user enters a positive integer as input. You may assume that a Scanner object called input has already been created.
Q2) Which of the following best describes this code snippet? if (count != 400) System.out.println("Hello World!");
A) If the variable count is exactly equal to 400, "Hello World" will be printed.
B) If the variable count is not equal to 400, "Hello World" will be printed.
C) If the variable count is close to, but not greater than, 400, "Hello World" will be printed.
D) If the variable count is exactly equal to 399 or 401, "Hello World" will be printed.
E) This code will not compile.
Q3) Write a switch statement that switches on an integer variable named val. If val is 2 or 15, then output "Hello World." For all other values, output "Goodbye World."
Q4) It is possible to implement a switch statement using if statements. A)True B)False
To view all questions and flashcards with answers, click on the resource link above. Page 6

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) Write a method called containsPair that takes in three integer parameters and returns true if any two of the input parameters are the same.
Q2) 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
Q3) Explain why method overloading is useful.
Q4) A return statement is not required at the end of every method. A)True B)False
Q5) Write a method called maxOfThree that accepts three integer parameters and returns the largest of the three.
Q6) Write a method that prints your name, age, and major. The method should accept no parameters and return no value.
Q7) 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) 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
Q2) Write a short class that represents a panel with a single slider that has values from 0 to 250, with large tick marks in increments of 50 and small tick marks in increments of 10.
Q3) A panel is displayed as a separate window, but a frame can only be displayed as part of another container.
A)True
B)False
Q4) Which of the following event descriptions best describes the mouse entered event?
A) The mouse button is pressed down
B) The mouse button is pressed down and released without moving the mouse in between
C) The mouse pointer is moved onto a component
D) The mouse button is released
E) The mouse is moved while the mouse button is pressed down
To view all questions and flashcards with answers, click on the resource link above.

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) Which of the statements is true about the following code snippet?
int[] array = new int[25]; Array[25] = 2;
A) The integer value 2 will be assigned to the last index in the array.
B) The integer value 25 will be assigned to the second index in the array.
C) The integer value 25 will be assigned to the third value in the array.
D) This code will result in a compile-time error.
E) This code will result in a run-time error.
Q2) In Java, array indexes begin at 0 and end at one less than the length of the array.
A)True
B)False
Q3) Which of the following lines of code accesses the second element of the first array in a two-dimensional array of integers, numbers, and stores the result in a variable called num?
A) num = numbers[1][2];
B) num = numbers[0][1];
C) num = numbers.getElement(1, 2);
D) num = numbers.getElement(0, 1);
E) none of the above are correct
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) Draw a hierarchy of people at a University.
Q2) To invoke a parents constructor in a subclass, we use the
method.
A) abstract
B) construct
C) parent
D) super E) extends
Q3) It is possible to derive a class from an abstract class without overriding all of the parents abstract methods.
A)True
B)False
Q4) Consider an software system that will implement the following classes: Student, Professor, StaffMember, ContractWorker. List some common attributes of these classes. What would be a good abstract class from which these classes may be extended via inheritance?
Q5) Explain what it means for a child class to override a parent class. Why might this be useful?
Q6) Describe the behavior of the toString method and the equals method of the Object class.
10
Q7) Explain the relevance of the Object class to the Java programming language.
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) If a class implements an interface, it cannot extend another class.
A)True
B)False
Q2) In Java, a(n) ___________________ is a collection of constants and abstract methods.
A) polymorphic reference
B) abstract class
C) implementation
D) interface
E) iterator
Q3) The commitment to execute certain code to carry out a method invocation is referred to as _________________.
A) execution
B) binding
C) polymorphism
D) inheritance
E) none of the above
Q4) Can references to interface types be polymorphic? Explain.
Q5) Write an interface for a CD player. It should have the standard operations (i.e. play, stop, etc) that usual CD players have.
To view all questions and flashcards with answers, click on the resource link above. Page 11

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) In the Towers of Hanoi puzzle, it is legal to move a larger disk to a peg that already contains a smaller disk.
A)True
B)False
Q2) In the Towers of Hanoi puzzle __________________________________ .
A) it is legal to move a disk onto a peg that contains smaller disks.
B) it is legal to sit a disk aside, not on any peg.
C) it is illegal to move a disk onto a peg that contains only larger disks.
D) it is illegal to move a disk onto a peg that contains no other disks.
E) none of the above are true
Q3) Determining whether or not there is a path through a maze has a recursive solution.
A)True
B)False
Q4) Give a recursive definition of the sum of the first n integers, S(n).
Q5) The Towers of Hanoi puzzle cannot be solved iteratively.
A)True
B)False
Q6) Write a recursive method that computes the product of all of the even integers less than or equal to n.
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) Write a code fragment that will throw an ArithmeticException. Your code fragment should not use the throw statement.
Q2) Give two examples of methods in the Exception class that can be used to output information about the Exception.
Q3) The _________________ statement is used to begin exception propogation.
A) propogate
B) relay
C) throw
D) except
E) send
Q4) A(n) ____________________ is used to identify a block of statements that may cause an exception.
A) call-stack trace
B) error
C) catch block
D) try block
E) none of the above
Q5) What are the standard I/O streams?
Q6) What is exception prorogation, and how does it work in Java?
Page 13
To view all questions and flashcards with answers, click on the resource link above.

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) The ___________________ of an algorithm shows the relationship between the size of the problem and the value we hope to optimize.
A) growth function
B) growth analysis
C) size function
D) size analysis
E) none of the above
Q2) Explain how quick sort works.
Q3) In the binary search algorithm, if the number of elements in the search pool is even, which value is used as the midpoint? Explain.
Q4) ____________________ 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
Q5) Explain what O(1) means.
Q6) Explain how merge sort works.
To view all questions and flashcards with answers, click on the resource link above. Page 14

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) A balanced binary tree with m elements will have height ______________ .
A) 2m
B) 2<sup>m</sup>
C) log<sub>m</sub> 2
D) log<sub>2</sub> m
E) none of the above
Q2) What is the root of a tree?
Q3) What is a decision tree?
Q4) What is a disadvantage of implementing a tree as an array using computed links?
Q5) Which of the following best describes a balanced tree?
A) A balanced trees has all nodes at exactly the same level.
B) A balanced tree has no nodes at exactly the same level.
C) A balanced tree has half of the nodes at one level and half the nodes at another level.
D) A balanced tree has all of the nodes within one level of each other.
E) none of the above correctly describe a balanced tree.
Q6) Explain the implementation of a level-order traversal of a tree.
Q7) Explain the implementation of an postorder traversal.
Q8) How many leaves will be contained in a full binary tree of height 5?
Q9) Explain how a binary tree can be implemented using an array.
To view all questions and flashcards with answers, click on the resource link above. Page 15

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) A stack 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
Q2) In a radix sort, the radix refers to __________________________ .
A) a circular array
B) the number of elements being sorted
C) the range of values of the sort key
D) a stack
E) a queue
Q3) A stack is a LIFO structure.
A)True
B)False
Q4) In a linked implementation of a stack, a pushed element should be added to the end of the list.
A)True
B)False
Q5) List the five basic operations on a stack.
To view all questions and flashcards with answers, click on the resource link above. Page 16
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) What is special about the order in which the nodes are visited in an inorder traversal of a binary search tree.
Q2) Which of the following is always true when adding an element to a heap?
A) The new element will always be a leaf.
B) The new element will always be the root.
C) The new element will always be an internal node.
D) The new element will always have 2 children.
E) none of the above is always true
Q3) Suppose we have a class called BinaryTree that includes a find method. If we extend the class to create a BinarySearchTree class, should we override the find method or use it as is? Explain.
Q4) A heap sort sorts elements by constructing a heap out of them, and then removing them one at a time from the root.
A)True
B)False
Q5) What is the inorder successor of a node in a binary search tree?
Q6) In a maxheap, the largest element is always the root.
A)True
B)False

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

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) Explain how a breadth-first traversal of a graph works.
Q2) A complete graph on n vertices has n(n-1)/2 edges. A)True
B)False
Q3) What is a complete graph? How many edges are contained in a complete graph on n vertices?
Q4) 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
Q5) What does it mean for a graph to be connected?
Q6) Is every tree a graph? Is every graph a tree? Explain.
Q7) Consider the following undirected graph. vertices: 1, 2, 3, 4, 5 edges: (1,2),(3,4), (2,4), (2, 3) Is the graph acyclic?
Q8) Can a tree ever have a cycle? Explain.
Q9) What is the difference between a spanning tree and a minimum spanning tree? Page 18
To view all questions and flashcards with answers, click on the resource link above.
Page 19