

Programming Fundamentals
Textbook Exam Questions

Course Introduction
Programming Fundamentals introduces students to the core concepts of computer programming, focusing on problem-solving techniques, algorithmic thinking, and the foundational principles of software development. Through practical exercises and projects, students will learn about variables, data types, control structures, functions, arrays, and the basics of object-oriented programming. Emphasis is placed on developing logical reasoning, debugging strategies, and coding proficiency using a high-level programming language, preparing students for more advanced studies in computer science and software engineering.
Recommended Textbook
Java Software Solutions Foundations of Program Design 7th Edition by John Lewis
Available Study Resources on Quizplus
13 Chapters
820 Verified Questions
820 Flashcards
Source URL: https://quizplus.com/study-set/1550
Page 2

Chapter 1: Introduction
Available Study Resources on Quizplus for this Chatper
65 Verified Questions
65 Flashcards
Source URL: https://quizplus.com/quiz/30660
Sample Questions
Q1) Java is similar in syntax to what other high level language?
A) Pascal
B) Ada
C) C++
D) FORTRAN
E) BASIC
Answer: C
Q2) Considering that the Pentium IV processor runs at a clock speed of about 850 MHz. What clock speed might we expect from a Pentium chip that would be released in 3 years?
Answer: 3400 MHz or 3.4 GHz.
Explanation: The speed of processors has been doubling roughly every 18 months (1 1/2 years). So, in 3 years, the speed will probably have doubled twice, or be four times greater than it is now, 4 * 850 = 3400.
Q3) Java is a case-sensitive language meaning that Current, current and CURRENT will all reference the same identifier.
A)True
B)False
Answer: False
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
77 Verified Questions
77 Flashcards
Source URL: https://quizplus.com/quiz/30661
Sample Questions
Q1) As explained in the Software Failure, the Mars Lander most likely crash landed when its descent engines cut off too high over the Mars surface.
A)True
B)False
Answer: True
Q2) What is output if x = 0, y = 1 and z = 1?
A) 0
B) 0.0
C) 0.6666666666666666
D) 0.6666666666666667
E) 0.67
Answer: B
Q3) Using getCurrencyInstance( ) formats a variable, automatically inserting
A) decimal point for cents
B) dollar sign
C) percent sign
D) all three
E) A and B but not C
Answer: E
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
58 Verified Questions
58 Flashcards
Source URL: https://quizplus.com/quiz/30662
Sample Questions
Q1) What happens if you attempt to use a variable before it has been initialized?
A) A syntax error may be generated by the compiler
B) A runtime error may occur during execution
C) A "garbage" or "uninitialized" value will be used in the computation
D) A value of zero is used if a variable has not been initialized
E) Answers A and B are correct
Answer: E
Q2) Write a method to extract the initial from the first name. Answer: firstInitial = firstName.substring(0,1);
Q3) The names of the wrapper classes are just the names of the primitive data types, but with an initial capital letter.
A)True
B)False
Answer: False
Q4) The Random class' setSeed( ) method allows you to restart the pseudo-random number sequence.
A)True
B)False
Answer: True
To view all questions and flashcards with answers, click on the resource link above. Page 5
Chapter 4: Writing Classes
Available Study Resources on Quizplus for this Chatper
56 Verified Questions
56 Flashcards
Source URL: https://quizplus.com/quiz/30663
Sample Questions
Q1) Write a statement to instantiate a cube with a length of 3, width of 3, and height of 3.
Q2) What visibility modifiers would you use for the methods that move the elevator up one floor, move the elevator down one floor, that request the elevator, and that start the elevator moving?
Q3) All Java classes must contain a main method which is the first method executed when the Java class is called upon.
A)True
B)False
Q4) Write a toString method that returns the player's name, position and batting average formatted to have 1 digit to the left of the decimal and 3 digits to the right of the decimal. Assume DecimalFormat has been imported.
Q5) Accessors and mutators provide mechanisms for controlled access to a well-encapsulated class.
A)True
B)False
Q6) Write a statement to output the volume of the blue box.
Q7) Write the constructor, which is passed the player's name and position.
Q8) Write the constructor for this class.

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

Chapter 5: Conditionals and Loops
Available Study Resources on Quizplus for this Chatper
37 Verified Questions
37 Flashcards
Source URL: https://quizplus.com/quiz/30664
Sample Questions
Q1) Explain what is meant by short circuiting and provide an example of short circuiting a condition with && and provide an example of short circuiting a condition with | |.
Q2) In Java, selection statements consist of the if and if-else statements.
A)True
B)False
Q3) The expression (done | | s.compareTo(t) < 0) is True.
A)True
B)False
Q4) If x is currently 0, a = 0 and b = -5, what will x become after the above statement is executed?
A) 0
B) 2
C) 3
D) 4
E) 5
Q5) The statement if (a >= b) a++; else b--; will do the same thing as the statement if (a < b) b--; else a++;.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 7

Chapter 6: More Conditionals and Loops
Available Study Resources on Quizplus for this Chatper
36 Verified Questions
36 Flashcards
Source URL: https://quizplus.com/quiz/30665
Sample Questions
Q1) If a switch statement is written that contains no break statements whatsoever,
A) this is a syntax error and an appropriate error message will be generated
B) each of the case clauses will be executed every time the switch statement is encountered
C) this is equivalent to having the switch statement always take the default clause, if one is present
D) this is not an error, but nothing within the switch statement ever will be executed
E) none of the above
Q2) The size of each rectangle (bar)
A) increases in height while staying the same width
B) increases in width while staying the same height
C) increases in both width and height
D) stays the same size
E) decreases in height while staying the same width
Q3) A dialog box is a device which accepts voice commands.
A)True
B)False
Q4) Describe a situation where you should use a do loop and a situation where you should use a while loop.
To view all questions and flashcards with answers, click on the resource link above. Page 8

Chapter 7: Object-Oriented Design
Available Study Resources on Quizplus for this Chatper
76 Verified Questions
76 Flashcards
Source URL: https://quizplus.com/quiz/30666
Sample Questions
Q1) During program development, software requirements specify
A) how the program will accomplish the task
B) what the task is that the program must perform
C) how to divide the task into subtasks
D) how to test the program when it is done
E) all of the above
Q2) Java does not support multiple inheritance, but some of the abilities of multiple inheritance are available by A) importing classes
B) implementing interfaces
C) overriding parent class methods
D) creating aliases
E) using public rather than protected or private modifiers
Q3) Write a set of code that will allow a user to select an input image and then place this image in a JLabel lab1 and add lab1 to a JPanel as the northern component in a JFrame using BorderLayout. The JFrame has already been instantiated as jf and the BorderLayout already established. Hint: a JFileChooser returns a File and JLabel requires the String name of a file as an argument. A File can return its name using File class' method getAbsolutePath( )
To view all questions and flashcards with answers, click on the resource link above.
Page 9

Chapter 8: Arrays
Available Study Resources on Quizplus for this Chatper
70 Verified Questions
70 Flashcards
Source URL: https://quizplus.com/quiz/30667
Sample Questions
Q1) Just as arrays can only have a fixed number of elements, set at the time the array is declared, a parameter list also can only have a fixed number of elements, set at the time the method is declared.
A)True
B)False
Q2) To swap the 3 and 4 elements in the int array values, you would do: values[3] = values[4]; values[4] = values[3];
A)True
B)False
Q3) Write code fragment to swap the two Strings stored by variables a and b.
Q4) Write a method to output all elements of a two-dimensional array of int values as a table of rows and columns. Use "\t" to get elements to line up properly. The method is passed the two-dimensional array and two int values that denote the number of both dimensions (rows followed by columns).
Q5) The length operator can be used to control a for-loop that iterates through each element of an array, as in for (int j=0; j<list.length; j++)
However, this is not necessarily safe. Why not?
To view all questions and flashcards with answers, click on the resource link above. Page 10

Chapter 9: Inheritance
Available Study Resources on Quizplus for this Chatper
71 Verified Questions
71 Flashcards
Source URL: https://quizplus.com/quiz/30668
Sample Questions
Q1) If you instantiate an Abstract class, the class or object you wind up with A) is also an Abstract class
B) is a normal class
C) is an Interface
D) is a reference to an Object
E) can't exist you cannot instantiate an Abstract class
Q2) A mouse event is generated by
A) moving the mouse
B) clicking the mouse button
C) double clicking the mouse button
D) dragging the mouse
E) all of the above
Q3) The assignment statement d = p; is legal even though d is not a Poodle.
A)True
B)False
Q4) An Applet implements MouseMotionListener. Write the mouseMoved and paint methods for an applet that will display the location of the mouse as an (x, y) coordinate. The output should be given at location (10, 10) of the applet no matter where the mouse is.
Q5) What methods inherited from Car should SportsCar override?
Page 11
To view all questions and flashcards with answers, click on the resource link above.

Chapter 10: Polymorphism
Available Study Resources on Quizplus for this Chatper
70 Verified Questions
70 Flashcards
Source URL: https://quizplus.com/quiz/30669
Sample Questions
Q1) Write a set of code to define a vertical JSlider that goes from 1 to 1000 with tick marks every 100 and default to be set in the middle (at 500), with a background color of 0, 0, 255.
Q2) What is the efficiency of binary search?
A) n²
B) n
C) log n
D) n/2
E) none of the above
Q3) What kind of performance can you expect if you perform linear search on a sorted array?
A) The performance will be about the same as on an unsorted array
B) The performance will be much better than on an unsorted array
C) The performance will be much worse than on an unsorted array
D) The performance will be worse than ² in this case
E) none of the above
Q4) What is early binding?
What is late binding?
Q5) Is it possible to use both overloading and overriding in the same method?
Q6) Explain why an abstract method cannot be declared private.
Page 12
To view all questions and flashcards with answers, click on the resource link above.

Chapter 11: Exceptions
Available Study Resources on Quizplus for this Chatper
68 Verified Questions
68 Flashcards
Source URL: https://quizplus.com/quiz/30670
Sample Questions
Q1) A combo box generates an item event when the user makes a selection.
A)True
B)False
Q2) Write a set of code that will allow a user to select a file through a JFileChooser and store all items in the String array list to the selected file, closing the file when done.
Q3) A mnemonic is
A) always a single character
B) can be a collection of characters and/or other keys
C) represents an inactive or disabled component
D) can be used instead of a tool tip
E) none of the above
Q4) In order to define a keyboard input object, keyboard, you could use the instruction: BufferedReader keyboard = new BufferedReader(System.in);
A)True
B)False
Q5) Write a set of code that will allow a user to select a file through a JFileChooser, read each item of the file, outputting each item to the screen, and close the file at the end.
To view all questions and flashcards with answers, click on the resource link above.
Page 13

Chapter 12: Recursion
Available Study Resources on Quizplus for this Chatper
68 Verified Questions
68 Flashcards
Source URL: https://quizplus.com/quiz/30671
Sample Questions
Q1) We can define a list of int values recursively as: a list_item, followed by a comma, followed by a list where a list_item is any int value.
A)True
B)False
Q2) The Euclidean algorithm for calculating the greatest common divisor (gcd) of two integers a and b is: "If a is a nonnegative integer, b is a positive integer, and r = a mod b, then gcd(a,b) = gcd(b,r). Write a recursive method that uses the Euclidean algorithm to calculate the gcd.
Q3) What is a fractal?
A) a portion of a larger structure (a fraction)
B) a geometric shape that can be made up of the same pattern repeated at different scales and orientations
C) a recursively defined numeric function
D) a ratio (a fraction)
E) none of the above
Q4) For the Towers of Hanoi problem, show how many moves it will take to solve the problem with 5 disks, 6 disks, 7 disks, 8 disks, 9 disks, and 10 disks.
Q5) Explain what a "base case" is in a recursive method.
To view all questions and flashcards with answers, click on the resource link above. Page 14

Chapter 13: Collections
Available Study Resources on Quizplus for this Chatper
68 Verified Questions
68 Flashcards
Source URL: https://quizplus.com/quiz/30672
Sample Questions
Q1) A linked list that stores int values would be comprised of a group of Nodes. We might define the Node by
A) class Node { Node next; }
B) class Node { Int next; }
C) class Node { Int data; }
D) class Node { Int data; Node next; }
E) class Node { Int[ ] data; Node next; }
Q2) Draw this structure.
To view all questions and flashcards with answers, click on the resource link above.
Page 15