Skip to main content

Programming Fundamentals Exam Practice Tests - 2169 Verified Questions

Page 1


Programming Fundamentals

Exam Practice Tests

Course Introduction

Programming Fundamentals introduces students to the foundational concepts of computer programming using a widely-used programming language. The course covers essential topics such as variables, data types, operators, control structures (conditionals and loops), functions, and basic input/output operations. Students will develop problem-solving strategies by writing, testing, and debugging simple programs. Emphasis is placed on logical thinking, algorithmic design, and clarity of code, preparing students for further studies in computer science and software development.

Recommended Textbook

Big Java Late Objects 1st Edition by Cay S. Horstmann

Available Study Resources on Quizplus

24 Chapters

2169 Verified Questions

2169 Flashcards

Source URL: https://quizplus.com/study-set/3769 Page 2

Chapter 1: Introduction

Available Study Resources on Quizplus for this Chatper

96 Verified Questions

96 Flashcards

Source URL: https://quizplus.com/quiz/75165

Sample Questions

Q1) A Java "class" file

A) contains Java source code

B) contains instructions to the Java virtual machine

C) is an internal file created by the Integrated Development Environment (IDE)

D) is the translation of the Java source code into C++

Answer: B

Q2) Because Java was designed for the Internet, which two of its attributes make it suitable for beginning programmers?

A) Efficiency and portability

B) Safety and security

C) Safety and portability

D) Efficiency and security

Answer: C

Q3) In order to translate a Java program to a class file, the computer needs to have software called a(n):

A) assembler

B) virtual machine

C) compiler

D) debugger

Answer: C

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

Chapter 2: Fundamental Data Types

Available Study Resources on Quizplus for this Chatper

103 Verified Questions

103 Flashcards

Source URL: https://quizplus.com/quiz/75166

Sample Questions

Q1) Which of the following statements is correct about constants?

A) Constants are written using uppercase letters because the compiler ignores constants declared in lowercase letters.

B) The data stored inside a final variable can be changed using an assignment statement.

C) You can make a variable constant by using the constant reserved word while declaring the variable.

D) Variables defined using final make a code snippet more readable and easier to maintain.

Answer: D

Q2) Which of the following options defines an integer variable?

A) char age;

B) integer age;

C) int age;

D) age: int;

Answer: C

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

4

Chapter 3: Decisionseasy

Available Study Resources on Quizplus for this Chatper

99 Verified Questions

99 Flashcards

Source URL: https://quizplus.com/quiz/75167

Sample Questions

Q1) Consider the following code snippet:

Int score = 0;

Double price = 100;

If (score > 0 && price < 200 && price / score > 10)

{ System.out.println("buy");

}

Which of the following statements is true on the basis of this code snippet?

A) The output is buy.

B) The code snippet compiles and runs, but there is no output.

C) The code snippet doesn't compile.

D) The code snippet causes a divide-by-zero error.

Answer: B

Q2) Which of the following options refers to the technique of simulating program execution on a sheet of paper?

A) Compiling

B) Prototyping

C) Tracing

D) Debugging

Answer: C

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

Page 5

Chapter 4: Loops

Available Study Resources on Quizplus for this Chatper

100 Verified Questions

100 Flashcards

Source URL: https://quizplus.com/quiz/75168

Sample Questions

Q1) What is the output of the following code fragment?

Int i = 1;

Int sum = 0;

While (i <= 11)

{ Sum = sum + i;

I++;

} System.out.println("The value of sum is " + sum);

A) The value of sum is 65

B) The value of sum is 66

C) The value of sum is 55

D) The value of sum is 56

Q2) What is the data type of the number generated by the Math.random() function?

A) double

B) float

C) int

D) String

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

Chapter 5: Methods

Available Study Resources on Quizplus for this Chatper

94 Verified Questions

94 Flashcards

Source URL: https://quizplus.com/quiz/75169

Sample Questions

Q1) Based on the code snippet, which of the following statements is correct?

Public static void reoccur(int count)

{ System.out.println(count); Reoccur(count + 1);

}

Public static void main(String[] args)

{ Reoccur(1);

}

A) The code snippet gives a compilation error as the reoccur method cannot call itself.

B) The code snippet executes and infinitely recurses, displaying 1, 2, 3, 4, and so on.

C) The code snippet executes and displays 1.

D) The code snippet executes and does not produce any output.

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

Chapter 6: Arrays and Arraylists

Available Study Resources on Quizplus for this Chatper

100 Verified Questions

100 Flashcards

Source URL: https://quizplus.com/quiz/75170

Sample Questions

Q1) The binary search is faster than the linear search, providing

A) the size of the array is a power of two.

B) the elements of the array are ordered.

C) the elements of the array are unordered.

D) the element being searched for is actually in the array.

Q2) Consider the following code snippet:

Int val = arr[0][2];

Which value of arr is stored in the val variable?

A) The value in the first row and the second column

B) The value in the first row and the first column

C) The value in the first row and the third column

D) The value in the third row and the second column

Q3) Consider using a deck of cards as a way to visualize a shuffle algorithm. When two cards shuffle their position, what has to happen to the size of the array holding them?

A) it increases by one

B) it decreases by one

C) it stays the same

D) it increases by two

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

Chapter 7: Inputoutput and Exception Handling

Available Study Resources on Quizplus for this Chatper

100 Verified Questions

100 Flashcards

Source URL: https://quizplus.com/quiz/75171

Sample Questions

Q1) Consider the following code snippet: If (in.hasNextDouble())

{ Number = in.nextDouble();

} Result = in.next();

If the input contains the characters 626.14 average, what values will number and result have after this code is executed?

A) number will contain the value 626 and result will contain the value 14.

B) number will contain the value 626.14 and result will contain the value average.

C) number will contain the value 0 and result will contain the value 626.14.

D) number will contain the value 0 and result will contain the value average.

Q2) The Scanner class's ____ method is used to specify a pattern for word boundaries when reading text.

A) useDelimiter()

B) usePattern()

C) setDelimiter()

D) setPattern()

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

9

Chapter 8: Objects and Classes

Available Study Resources on Quizplus for this Chatper

101 Verified Questions

101 Flashcards

Source URL: https://quizplus.com/quiz/75172

Sample Questions

Q1) Insert the missing code in the following code fragment. This fragment is intended to initialize an instance variable.

Public class Motor

{

Int motorSpeed; Public Motor(int speed) { MotorSpeed = speed; } Public Motor()

Which of the following lines of code will allow the second constructor to call the first constructor?

A) this.motorspeed(0);

B) this(0);

C) this(speed);

D) You cannot call a constructor from within another constructor.

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

Page 10

Chapter 9: Inheritance and Interfaces

Available Study Resources on Quizplus for this Chatper

99 Verified Questions

99 Flashcards

Source URL: https://quizplus.com/quiz/75173

Sample Questions

Q1) Which of the following statements about a Java interface is NOT true?

A) A Java interface defines a set of methods that are required.

B) A Java interface must contain more than one method.

C) A Java interface specifies behavior that a class will implement.

D) All methods in a Java interface must be abstract.

Q2) To define a class that fulfills the requirements of an interface, the class header should include which of the following?

A) The keyword extends and the name of an abstract method in the interface

B) The keyword extends and the name of the interface

C) The keyword implements and the name of an abstract method in the interface

D) The keyword implements and the name of the interface

Q3) Which reserved word must be used to call a method of a superclass?

A) this

B) my

C) parent

D) super

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

Chapter 10: Graphical User Interfaces

Available Study Resources on Quizplus for this Chatper

54 Verified Questions

54 Flashcards

Source URL: https://quizplus.com/quiz/75174

Sample Questions

Q1) When an event occurs, the event source notifies all associated ____.

A) components

B) panels

C) interfaces

D) event listeners

Q2) What is the nickname for the graphical user interface library in Java?

A) Applet

B) GUI

C) JComponent

D) Swing

Q3) Which java package must be imported if a program wishes to respond to button events?

A) javax.swing.event.ActionListener

B) java.awt.event.ActionListener

C) javax.swing.JButton

D) java.awt.JButton

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

12

Chapter 11: Advanced User Interfaces

Available Study Resources on Quizplus for this Chatper

91 Verified Questions

91 Flashcards

Source URL: https://quizplus.com/quiz/75175

Sample Questions

Q1) You wish to detect when the mouse is moved into a graphical component. Which methods of the associated MouseListener interface will provide this information?

A) mouseMoved

B) mouseEntered

C) mouseOver

D) mouseIncoming

Q2) What type of object can be added into a JComboBox by the addItem method?

A) Object

B) String

C) JRadioButton

D) any non-primitive type

Q3) What is known for certain from this correct code excerpt?

ActionListener openListener = new FileOpenListener();

JMenuItem fileOpen = new JMenuItem("Open File");

FileOpen.addActionListener(openListener);

A) fileOpen will open a file dialog when clicked

B) The fileOpen menu item will be visible

C) The FileOpenListener class implements the ActionListener interface

D) The openListener object will only listen to the fileOpen object

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

Chapter 12: Object-Oriented Design

Available Study Resources on Quizplus for this Chatper

100 Verified Questions

100 Flashcards

Source URL: https://quizplus.com/quiz/75176

Sample Questions

Q1) If you do not include a package statement at the top of your class source file, its classes will be placed in which package?

A) java.lang

B) java.util

C) the default package, which has no name

D) java.awt

Q2) Before you begin designing a solution, you should ____.

A) Document the methods that will be needed.

B) Gather and document all requirements for the program in plain English.

C) Determine the classes that will be needed.

D) Create the UML diagrams to represent the classes.

Q3) The dependency relationship is sometimes referred to as the ____ relationship.

A) is-a

B) has-a

C) depends-on

D) knows-about

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

14

Chapter 13: Recursion

Available Study Resources on Quizplus for this Chatper

100 Verified Questions

100 Flashcards

Source URL: https://quizplus.com/quiz/75177

Sample Questions

Q1) Consider the recursive version of the fib method from the textbook shown below: Public static long fib(int n)

{ If (n <= 2)

{ Return 1; } Else

{ Return fib(n - 1) + fib(n - 2); } }

How many total recursive calls (not counting the original call) to fib will be made from the original call of fib(7)?

A) 12

B) 24

C) 30

D) 32

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

Page 15

Chapter 14: Sorting and Searching

Available Study Resources on Quizplus for this Chatper

99 Verified Questions

99 Flashcards

Source URL: https://quizplus.com/quiz/75178

Sample Questions

Q1) If you implement a recursive linear search, its performance will be ____.

A) O(n)

B) O(n<sup>2</sup>)

C) O(log (n))

D) O(n log (n))

Q2) In each iteration, selection sort places which element in the correct location?

A) The smallest in the array.

B) The smallest element not yet placed in prior iterations.

C) The largest element in the array.

D) A random element.

Q3) Which selection sort iteration guarantees the array is sorted for a 10-element array?

A) 9<sup>th</sup> iteration

B) 10<sup>th</sup> iteration

C) 1<sup>st</sup> iteration

D) impossible to tell

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

16

Chapter 15: The Java Collections Framework

Available Study Resources on Quizplus for this Chatper

100 Verified Questions

100 Flashcards

Source URL: https://quizplus.com/quiz/75179

Sample Questions

Q1) Which of the following correctly declares a stack that will hold String elements?

A) Stack&lt;String&gt; s = new Stack&lt;String&gt;();

B) Stack s = new Stack&lt;String&gt;();

C) String s = new Stack&lt;String&gt;();

D) String s = new Stack();

Q2) What type of access does a LinkedList provide for its elements?

A) sequential

B) semi-random

C) random

D) sorted

Q3) Suppose we create a deque (double-ended queue) data structure. It is basically a queue, with its addLast and removeFirst operations, but we also add the addFirst and removeLast operations. Which of the following is best modeled by the deque data structure?

A) A toll booth on a highway.

B) A cross country race.

C) A computer keyboard typing buffer.

D) A Memorial Day parade.

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

Chapter 16: Basic Data Structures

Available Study Resources on Quizplus for this Chatper

94 Verified Questions

94 Flashcards

Source URL: https://quizplus.com/quiz/75180

Sample Questions

Q1) Assume that you have a hash table in which there are an average number of collisions. What is the time required to add an element to this hash table?

A) O(n)

B) O(n<sup>2</sup>)

C) O(1)

D) O(1)+

Q2) Which of the following actions must be taken to add a node X at the beginning of a doubly-linked list?

I Update the next reference in the node before the position where X will be placed

II Update the previous reference in the node after the position where X will be placed III Update the list's first reference

A) I

B) II

C) I and II

D) II and III

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

18

Chapter 17: Tree Structures

Available Study Resources on Quizplus for this Chatper

100 Verified Questions

100 Flashcards

Source URL: https://quizplus.com/quiz/75181

Sample Questions

Q1) How many times during the heapsort algorithm does the fixHeap method need to be called for a max-heap with n elements?

A) log(n)

B) n-1

C) n

D) n+1

Q2) Removing an element from a balanced binary search tree takes ____ time.

A) O(n)

B) O(log (n))

C) O(1)

D) O(n<sup>2</sup>)

Q3) Which of the following sequences of insertions will result in a balanced tree?

I 12 , 7, 25, 6, 9, 13, 44

II 12 , 7, 25, 44, 13, 6, 9

III 12, 25, 44, 13, 6, 9, 7

A) I

B) II

C) I and II

D) I and III

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

Page 19

Chapter 18: Generic Classes

Available Study Resources on Quizplus for this Chatper

78 Verified Questions

78 Flashcards

Source URL: https://quizplus.com/quiz/75182

Sample Questions

Q1) Which of the following statements about generic methods is correct?

A) You must instantiate the type parameter when calling a generic method.

B) You must specify which type to use when calling a generic method.

C) Generic methods cannot be static methods.

D) You cannot replace type parameters with primitive types.

Q2) Which of the following satisfies the wildcard ? extends Object?

I String

II JComponent

III Scanner

A) I

B) II

C) I and II

D) I, II and III

Q3) What is known for certain about Visualizer when a method constrains its type parameter as follows?

&lt;E extends Visualizer&gt;

A) Visualizer must refer to a class

B) Visualizer must refer to an interface

C) Visualizer can refer to either an interface or a class

D) Visualizer is another generic type

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

Chapter 19: Streams and Binary Inputoutput

Available Study Resources on Quizplus for this Chatper

82 Verified Questions

82 Flashcards

Source URL: https://quizplus.com/quiz/75183

Sample Questions

Q1) When constructing a Scanner from a File object, the Scanner automatically constructs a ___________.

A) InputStream

B) FileInputStream

C) FileReader

D) PrintWriter

Q2) How many methods are required to implement the Serializable interface?

A) 3

B) 2

C) 1

D) 0

Q3) Which methods are not in the Serializable interface?

I readObject

II writeObject

III serializeObject

A) I

B) I and II

C) II and III

D) I, II, and III

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

Page 21

Chapter 20: Multithreading

Available Study Resources on Quizplus for this Chatper

82 Verified Questions

82 Flashcards

Source URL: https://quizplus.com/quiz/75184

Sample Questions

Q1) Stale data occurs in multi-CPU machines when one thread modifies shared data and a second thread accesses that data later, but sees the data value before the change took place. What is required to guarantee that the second thread sees the updated data, not stale data when access to the shared data occurs in two different methods?

A) One method needs to acquire then release the lock after modifying the data.

B) Both methods need to acquire then release the lock after modifying or reading the data.

C) Never change any shared object data in multi-CPU machines.

D) Never use locks for any shared data in multi-CPU machines.

Q2) In which method are the tasks that are performed by a thread coded?

A) start

B) main

C) run

D) init

Q3) What should be done to get the attention of a thread?

A) call the thread's stop method

B) call the thread's run method

C) call the thread's interrupt method

D) call the thread's sleep method

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

Chapter 21: Internet Networking

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

Source URL: https://quizplus.com/quiz/75185

Sample Questions

Q1) _______ ________ was developed to enable different local area networks to communicate with each other and has become the basis for connecting computers around the world over the Internet.

A) TCP

B) IP

C) FTP

D) HTTP

Q2) The ____________ has one function, to attempt to deliver data from one computer to another across the Internet.

A) TCP/IP

B) IP

C) HTTP

D) DNS

Q3) What does the following if statement do?

If (code == HttpURLConnetion.HTTP_OK)

A) It checks if the code is 200.

B) It checks if the code is 404.

C) It checks if the connection is still connected.

D) It checks if there is HTTP.

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

Page 23

Chapter 22: Relational Databases

Available Study Resources on Quizplus for this Chatper

75 Verified Questions

75 Flashcards

Source URL: https://quizplus.com/quiz/75186

Sample Questions

Q1) Insert the statement that would remove the following table from the database. CREATE TABLE Course

( Course_ID VARCHAR(11), Credits VARCHAR(4), Room_No INT(4) )

A) DELETE TABLE Course

B) TRUNCATE TABLE Course

C) DROP Course

D) DROP TABLE Course

Q2) Which Java statement connects to a database using a Connection object?

A) Connection conn = new Connection(url, username, password);

B) Conenction conn = DriverManager.getConnection();

C) Connection conn = DriverManager.connect(url, username, password);

D) Connection conn = DriverManager.getConnection(url, username, password);

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

24

Chapter 23: XML

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

Source URL: https://quizplus.com/quiz/75187

Sample Questions

Q1) What method do you use to insert a node into an XML document?

A) insertNode method.

B) createNode method.

C) createElement method.

D) insertElement method.

Q2) In an attribute definition in a DTD, a #REQUIRED declaration means ____________.

A) the attribute is valid.

B) the attribute is required.

C) the attribute is optional.

D) the attribute is implied.

Q3) Which of the following statements is correct?

A) XML is an extensible syntax that can be used to specify many different kinds of data.

B) XML has one specific purpose: to describe web documents.

C) XML tells you how to display data.

D) You can always replace XML elements with attributes.

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

Chapter 24: Web Applications

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

Source URL: https://quizplus.com/quiz/75188

Sample Questions

Q1) A _______ is an application whose user interface is displayed in a web browser.

A) server application

B) web application

C) client application

D) internet application

Q2) The user interface of a web application is displayed in a ______.

A) protocol

B) server browser

C) web browser

D) web server

Q3) The part of the web application that is independent of the graphical user interface is called:

A) Swing.

B) presentation logic.

C) business logic.

D) HTML.

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

Turn static files into dynamic content formats.

Create a flipbook
Programming Fundamentals Exam Practice Tests - 2169 Verified Questions by Quizplus - Issuu