Skip to main content

Object-Oriented Programming Exam Bank - 2169 Verified Questions

Page 1


Object-Oriented Programming Exam Bank

Course Introduction

Object-Oriented Programming is a foundational course that introduces students to the principles and techniques of organizing software using objects, classes, inheritance, encapsulation, and polymorphism. Through a combination of lectures, hands-on projects, and coding exercises, students learn to model real-world problems by designing reusable and maintainable code structures. The course emphasizes the development of problem-solving skills and best practices in programming using an object-oriented language, preparing students for advanced topics in software development and engineering.

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) These two lines of code do not produce the same output. Why?

System.out.println(7 + 3); System.out.println("7 + 3");

A) Arithmetic calculations cannot take place within the println method call.

B) In fact, the two statements do produce the same output.

C) The quotes cause the second expression to be treated as a string.

D) Because there are no escape characters.

Answer: C

Q2) Consider the following statements about folders and your integrated development environment (IDE):

I. Hierarchical folders help to organize a project.

II. Folders are a way to visualize the layout of a file system.

III. Folders make it impossible to lose or accidentally delete a file.

A) Only I is correct

B) I, II, and III are correct

C) Only I and II are correct

D) Only III is correct

Answer: C

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

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 places input into the variable value given this line of code?

Scanner in = new Scanner(System.in);

A) int value = in();

B) int value = in.nextInt();

C) int value = in.next();

D) int value = in.nextFloat();

Answer: B

Q2) Which one of the following statements can be used to convert a string str to a double?

A) double n = str.parseDouble();

B) double n = Integer.parseDouble(str);

C) double n = Double.parseDouble(str);

D) double n = double.parseDouble(str);

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) What is the value of the cost variable after the following code snippet is executed?

Int cost = 82;

If (cost < 100)

Cost = cost + 10;

If (cost > 50)

Cost = cost * 2;

If (cost < 100)

Cost = cost - 20;

A) 82 B) 92

C) 184

D) 164

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) Insert a statement that will correctly terminate this loop when the end of input is reached.

Boolean done = false; While (!done)

{ String input = in.next(); If (input.equalsIgnoreCase("Q"))

{ } Else

{ Double x = Double.parseDouble(input); Data.add(x);

}

}

A) stop; B) done = 1; C) exit;

D) done = true;

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) For a program that reads three letter grades and calculates an average of those grades, which of the following would be a good design based on stepwise refinement?

A) Write one method that reads three letter grades, converts each letter grade to a number, and calculates the average of the three numbers.

B) Write one method that reads three letter grades, and a second method to convert each letter to a number and calculate the average of the three numbers.

C) Write one method that reads a letter grade and returns the number equivalent, and one method that computes the average of three numbers.

D) Stepwise refinement cannot be applied to this problem.

Q2) The term "Black Box" is used with methods because

A) Only the implementation matters; the specification is not important.

B) Only the specification matters; the implementation is not important.

C) Only the arguments matter; the return value is not important.

D) Only the return value matters; the arguments are not important.

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) Consider the following code snippet, where the array lists contain elements that are stored in ascending order:

ArrayList&lt;Integer&gt; list1 = new ArrayList&lt;Integer&gt;(); ArrayList&lt;Integer&gt; list2 = new ArrayList&lt;Integer&gt;();

) . .

Int count = 0;

For (int i = 0; i &lt; list1.size() && i &lt; list2.size(); i++)

{ If (list1.get(i) == list2.get(i))

{ Count++;

Which one of the following descriptions is correct for the given code snippet?

A) The code snippet finds the highest value out of the two array lists.

B) The code snippet finds the lowest value out of the two array lists.

C) The code snippet compares the values of two array lists and stores the count of total matches found.

D) The code snippet adds the values of the two array lists.

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

8

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: Throw IllegalStateException("This operation is not allowed!");

Which of the following statements about this code is correct?

A) This code constructs an object of type IllegalArgumentException and throws the object.

B) This code throws an existing IllegalArgumentException object.

C) This code constructs an object of type IllegalArgumentException and reserves it for future use.

D) This code will not compile.

Q2) Consider the following code snippet: PrintWriter out = new PrintWriter("output.txt");

Which of the following statements about the PrintWriter object is correct?

A) If a file named "output.txt" already exists, an exception will occur.

B) If a file named "output.txt" already exists, data will be added at the end of the file.

C) If a file named "output.txt" already exists, existing data will be deleted before data are added to the file.

D) If a file named "output.txt" already exists, a new file named "output_1.txt" will be created and used.

To view all questions and flashcards with answers, click on the resource link above. Page 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) Which of the following statements about constructors is NOT correct?

A) A constructor must have the same name as the class name.

B) A call to a constructor must always have construction parameters.

C) A constructor initializes the instance variables of an object.

D) A class can have more than one constructor.

Q2) If you do not provide a constructor in a class, which of the following is correct?

A) The compiler will generate a constructor with arguments for each class instance variable and will initialize all of the class instance variables.

B) The compiler will generate a constructor with no arguments.

C) The compiler will generate a constructor with arguments for each class instance variable.

D) The class code will not compile.

Q3) Which of the following declares a rpmRating instance variable for a Motor class that stores an integer value?

A) private integer rpmRating;

B) private int rpmRating;

C) public integer rpmRating;

D) public int rpmRating;

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

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) Consider the following code snippet: Int vacationDays = 10;

String output = "Number of earned vacation days is " + vacationDays; Which of the following statements is correct?

A) The toString method of the Object class is being used to set the value of output.

B) The toString method of the Integer class is being used to set the value of output.

C) No toString method is being used to set the value of output.

D) This code will not compile.

Q2) Which of the following is true regarding inheritance?

A) When creating a subclass, all methods of the superclass must be overridden.

B) When creating a subclass, no methods of a superclass can be overridden.

C) A superclass can force a programmer to override a method in any subclass created from it.

D) A superclass cannot prevent a programmer from overriding a method in any subclass created from it.

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) Which of the following statements about listener classes is true?

A) A listener class can be declared as an anonymous inner class.

B) A listener class cannot be declared as an inner class.

C) A listener class must be declared as an inner class.

D) A listener class must be declared as an anonymous inner class.

Q2) User-interface components are arranged by placing them inside ____________________.

A) Swing components

B) borders

C) JPanels

D) containers

Q3) The methods of a/an ____ describe the actions to be taken when an event occurs.

A) event source

B) event listener

C) event interface

D) action source

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

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) What is the container for top-level menu items?

A) menu bar

B) menu item

C) menu GUI

D) top level menus don't use containers

Q2) What is the default layout manager of the content pane of a JFrame?

A) FlowLayout

B) GridLayout

C) BoxLayout

D) BorderLayout

Q3) What features do GUI builders have to speed the development of the graphical user interface of the program?

I setting properties of dialog boxes

II automated event-handling code generation

III drag and drop of visual components

A) I

B) 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 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) Which of the following statements is correct?

A) Dependency is a stronger form of aggregation.

B) Aggregation indicates high cohesiveness.

C) Aggregation indicates low coupling.

D) Aggregation is a stronger form of dependency.

Q2) Which of the following code snippets denotes that the Fleet class aggregates the Taxi class?

A) public class Fleet extends Taxi

B) public class Taxi extends Fleet

C) public class Fleet

{ Private ArrayList&lt;Taxi&gt; taxicabs; }

D) public class Taxi

{ Private Fleet myFleet;

}

To view all questions and flashcards with answers, click on the resource link above. Page 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) ____ is a problem-solving technique that examines partial solutions, abandons unsuitable ones, and returns to consider other candidate solutions.

A) Debugging

B) Traceback

C) Backtracking

D) Recursion

Q2) Which statement(s) about recursion are true?

I Recursion is faster than iteration

II Recursion is often easier to understand than iteration

III Recursive design has an economy of thought

A) I

B) II

C) II and III

D) I and III

Q3) In recursion, the non-recursive case is analogous to a loop ____.

A) call

B) iteration

C) termination

D) condition

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) Which of the following statements about running times of algorithms is correct?

A) An algorithm that is O(1) means that only one comparison takes place.

B) When determining the running time, constants are not taken into consideration.

C) When determining the running time, lower-order terms must be taken into consideration.

D) An algorithm that is O(n) means that the number of comparisons does not grow as the size of the array increases.

Q2) 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))

Q3) After one iteration of selection sort working on an array of 10 elements, what must hold true?

A) The array cannot be sorted.

B) One element must be correctly placed.

C) At least two elements are correctly placed.

D) The largest element is correctly placed.

To view all questions and flashcards with answers, click on the resource link above. Page 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) A linear search only requires ____ access.

A) sequential

B) random

C) sorted

D) arbitrary

Q2) Which method is NOT part of the ListIterator interface?

A) delete

B) add

C) next

D) previous

Q3) Assume you have created a linked list named myList that currently holds some number of String objects. Which of the following statements correctly adds a new element to the beginning of myList?

A) myList.addFirst("Harry");

B) myList.add("Harry");

C) myList.insert("Harry");

D) myList.put("Harry");

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

17

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) Consider the following code snippet: LinkedList&lt;String&gt; words = new LinkedList&lt;String&gt;(); Words.addFirst("123"); Words.addLast("456"); Words.addFirst("789"); System.out.print(words.removeLast()); System.out.print(words.removeFirst()); System.out.print(words.removeLast());

What does this code print?

A) 123456789

B) 789123456

C) 123789456

D) 456789123

Q2) Which Java package contains the LinkedList class?

A) java.lang

B) java.util

C) java.collections

D) java.io

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) Which of the following may occur as a result of an add operation, on a non-empty binary search tree?

I a new root is created

II the new node becomes the left child of the root

III the new node has a right child upon insertion

A) I

B) II

C) III

D) II and III

Q2) If the postorder traversal of an expression tree is 8, 2, +, 5, /, what is the preorder traversal?

A) +, /, 8, 2, 5

B) /, +, 8, 2, 5

C) 8, +, 2, /, 5

D) /, +, 2, 8, 5

Q3) 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>)

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) Determine the correctness of the MyLinkedList generic class code below.

Public class MyLinkedList&lt;E&gt;

{

Private MyNode first;

Public E getFirst() { return first.data; }

Private class MyNode

{

Private E data;

Private MyNode next; } }

A) MyNode cannot refer to type variable E

B) first.data will cause a compiler error

C) the inner class MyNode cannot be private

D) the code is correct

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

A) String

B) JComponent

C) Scanner

D) none satisfy this wildcard

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) You use _________ and FileOutputStream objects to write data to a disk file in text or binary form respectively.

A) FileReader

B) PrintWriter

C) OutputStreamWriter

D) ObjectOutputStream

Q2) What is the highest value for a signed (negative and positive) byte?

A) 127

B) 128

C) 255

D) 256

Q3) If you want to process text data from a file, which keyword do you look for in classes that specialize in doing that?

A) text

B) serializable

C) binary

D) reader

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

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) A(n) ____ object is used to control the threads that want to manipulate a shared resource.

A) condition

B) lock

C) interrupt

D) runnable

Q2) A waiting thread is blocked until another thread calls ____ on the condition object for which the thread is waiting.

A) await

B) signalAll

C) interrupt

D) lock

Q3) The ________ method is called by a thread that has just changed the state of some shared data in a way that may benefit waiting threads.

A) run

B) lock

C) unlock

D) signalAll

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

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) The HTTP command POST ____________.

A) returns the requested item.

B) supplies input to a server-side command and returns the result.

C) requests input from the server-side command.

D) supplies input to a client-side command.

Q2) A(n) ____ describes how data for a particular application is transmitted.

A) URL

B) application protocol

C) socket

D) IP address

Q3) For the server to execute the run method in a separate thread for each client, the application program needs to implement the _____ interface.

A) Running

B) Runtime

C) Server

D) Runnable

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) If you encounter an error during updating a transaction, then call the ______ method:

A) undo

B) takeback

C) rollaround

D) rollback

Q2) What does the execute method return?

A) ResultSet

B) Query

C) RecordSet

D) boolean

Q3) Apache Derby is an example of a:

A) Heavyweight Java database.

B) Lightweight Java database.

C) Desktop database.

D) Production-quality database.

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

Page 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) What package will you use to import DocumentBuilder?

A) javax.swing.DocumentBuilder

B) javax.xml.DocumentBuilder

C) javax.parsers.DocumentBuilder

D) javax.xml.parsers.DocumentBuilder

Q3) The ____ standard defines interfaces and methods to analyze and modify the tree structure that represents an XML document.

A) JAXP

B) SAX

C) DOM

D) API

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

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) The JSF technology enables the separation of :

A) HTML and Swing.

B) presentation and application.

C) business logic and presentation.

D) JSF and HTML.

Q2) JSF pages define the ___________ of a web application.

A) swings

B) presentation logic

C) business logic

D) value expressions

Q3) What does the value expression timeZoneBean.city do when it is part of the JSF tag &lt;h:inputText value="#{timeZoneBean.city}"/&gt;?

A) Sets the timeBean.city instance variable.

B) Calls the timeBean.setTime method

C) Calls the timeBean.setTime method method

D) Calls either the timeBean.setTime or timeBean.setTime method

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

26

Turn static files into dynamic content formats.

Create a flipbook