Object-Oriented Programming Final Exam - 2169 Verified Questions

Page 1


Object-Oriented Programming Final

Exam

Course Introduction

Object-Oriented Programming (OOP) introduces students to the fundamental concepts and practices of software development using the object-oriented paradigm. The course covers key principles such as encapsulation, inheritance, polymorphism, and abstraction, emphasizing how to model real-world problems as objects and classes. Students will learn to design, implement, test, and debug programs in an object-oriented language, understanding how to create modular, reusable, and maintainable code. Through practical assignments and projects, participants will gain hands-on experience with object-oriented design patterns, interfaces, and the effective use of software development tools, laying a strong foundation for advanced programming and application 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) In Java, the statement System.out.print("hello");;;

A) is a syntax error

B) is a legal statement

C) seems like it should print out "hello" but doesn't

D) asks the user to enter a value and stores it in the variable "hello"

Answer: B

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

Q3) An example of an input device that interfaces between computers and humans is

A) a microphone

B) a monitor

C) a printer

D) a speaker

Answer: A

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) What is wrong with the following code snippet? Int average;

Average = 78A;

A) The average variable is never initialized.

B) The data type for the average variable is not specified.

C) The average variable is never assigned a value.

D) The average variable is assigned a non-numeric value.

Answer: D

Q2) What output is produced by these statements?

String name = "Joanne Hunt"; System.out.println(name.length());

A) 8

B) 10

C) 9

D) 11

Answer: D

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) When an if statement is nested inside another if statement, it creates the possibility of

A) an infinite loop

B) the misuse of the break statement

C) type mismatch

D) The dangling else

Answer: D

Q2) Which of the following operators is used to invert a conditional statement?

A) !

B) !=

C) ||

D) \(?\)

Answer: A

Q3) Which of the following operators is used as a relational operator?

A) =<

B) <=

C) =

D) !

Answer: B

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) When hand-tracing the loop in the code snippet below, which variables are important to evaluate?

Int i = 10;

Int j = 5;

Int k = -10;

Int sum = 0;

While (i > 0)

{ Sum = sum + i + j;

I--;

System.out.println("Iteration: " + i);

}

A) The variables i and j

B) The variables i and sum

C) The variables i, j, and k

D) The variables j and k

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) A temporary method that is used to provide a quick way to test other methods is called:

A) Stub

B) Parameter

C) Caller

D) Assessor

Q2) Given the following method, what is the result of getNumber(n)?

Public static double getNumber(double n)

{ Return Math.pow(Math.sqrt(n), 2) - n;

}

A) Always 0 for every argument n

B) Always 2 for every argument n

C) Close to 0, but not always 0

D) Compilation error

Q3) An effective technique for understanding the subtle aspects of a method is to:

A) Perform a manual walkthrough.

B) Write stub methods.

C) Use the Java compiler to catch compile-time errors.

D) Write large methods to eliminate the run-time overhead of calling methods.

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

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) What is the output of the following code snippet?

ArrayList&lt;Integer&gt; num; Num)add(4); System.out.println(num.size());

A) 1

B) 0

C) 4

D) Error because num is not initialized

Q2) Which statements are true regarding the differences between arrays and array lists?

I. Arrays are better if the size of a collection will not change

II. Array lists are more efficient than arrays

III. Array lists are easier to use than arrays

A) I, II

B) I, III

C) II, III

D) I, II, III

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

Q2) Which of the following statements about using a PrintWriter object is NOT true?

A) A PrintWriter will be automatically closed when the program exits.

B) Data loss may occur if a program fails to close a PrintWriter object before exiting.

C) PrintWriter is an enhancement of the PrintStream class.

D) A program can write to a PrintWriter using println.

Q3) An example of a fatal error that rarely occurs and is beyond your control is the ____.

A) OutOfMemoryError

B) RuntimeException

C) FileNotFoundException

D) NumberFormatException

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) You have created a Coin class and a Purse class. Which of the following will correctly allow the Purse class to collect Coin objects?

A) public Purse

{

Private Coin ArrayList coins; }

B) public Purse

{

Private ArrayList coins; }

C) public Purse

{

Private ArrayList&lt;Coin&gt; coins; }

D) public Purse

{

Public ArrayList&lt;Coin&gt; coins; }

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) You are creating a Motorcycle class which is supposed to be a subclass of the Vehicle class. Which of the following class declaration statements will accomplish this?

A) public class Motorcycle extends Vehicle

B) public class Motorcycle implements Vehicle

C) public class Motorcycle interfaces Vehicle

D) public class Motorcycle inherits Vehicle

Q2) To ensure that an instance variable can only be accessed by the class that declared it, the variable should be declared as ____.

A) public

B) private

C) protected

D) final

Q3) Which statement about methods in an interface is true?

A) All methods in an interface are automatically private.

B) All methods in an interface are automatically public.

C) All methods in an interface are automatically static.

D) All methods in an interface must be explicitly declared as private or public.

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) What happens if a text field's width is set to 10 characters and the user types more characters into it?

A) The user interface automatically widens the field's width.

B) An InputMismatchException is thrown.

C) The earlier characters are deleted and only the last ten are shown and entered.

D) The characters are entered but only those that fit into the width are shown.

Q2) Use the ____ method to specify the height and width of a graphical component when you add it to a panel.

A) setPreferredDimensions.

B) setInitialDimensions.

C) setPreferredSize.

D) setInitialSize.

Q3) Which of the following statements creates a button with "Calculate" as its label?

A) Button JButton = new Button("Calculate")

B) button = new Button(JButton, "Calculate")

C) Button = new JButton("Calculate")

D) JButton button = new JButton("Calculate")

To view all questions and flashcards with answers, click on the resource link above. Page 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) Which component can generate action events?

I JMenuBar

II JMenu

III JMenuItem

A) I

B) II

C) III

D) II and III

Q2) What is the most time-effective way to build a GUI quickly and concentrate on coding the logic of the program?

A) use the GridBagLayout manager

B) use a GUI builder, such as NetBeans

C) use nested panels

D) use menus

Q3) What type of event does the JSlider class generate?

A) ChangeEvent

B) ActionEvent

C) ItemEvent

D) SliderEvent

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) A CashRegister class contains an array list of Coin objects. This is best described as an example of ____.

A) Association

B) Inheritance

C) Cohesiveness

D) Aggregation

Q2) To improve the quality of the public interface of a class, ____.

A) You should maximize cohesion and minimize inheritance.

B) You should minimize cohesion and maximize coupling.

C) You should maximize cohesion and minimize coupling.

D) You should minimize cohesion and maximize aggregation.

Q3) When using the CRC method, other classes that are needed to fulfill the responsibilities of a given class are called its ____.

A) Related classes.

B) Responsible classes.

C) Collaborators.

D) Concurrent classes.

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 following recursive code snippet: Public int mystery(int n, int m)

{ If (n == 0)

{ Return 0; } If (n == 1)

{ Return m; } Return m + mystery(n - 1, m); }

What parameter values for n would cause an infinite recursion problem in the following method?

A) n == 0

B) n == 1

C) all n with n < 0

D) all n with n >= 0

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) Given the following code snippet for searching an array:

Int[] arr = {3, 8, 12, 14, 17};

Int newVal = 15;

Int pos = Arrays.binarySearch(arr, newVal);

What value will pos have when this code is executed?

A) 5

B) -5

C) 6

D) -6

Q2) Which of the following classes implement the Comparable interface?

I Date

II Collections

III String

A) I

B) I and II

C) I and III

D) II and III

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) Consider the following code snippet: Map&lt;String, Integer&gt; scores;

If you need to visit the keys in sorted order, which of the following statements will create a structure to support this?

A) scores = new HashMap&lt;String, Integer&gt;;

B) scores = new TreeMap&lt;String, Integer&gt;;

C) scores = new Map&lt;String, Integer&gt;;

D) scores = new HashTable&lt;String, Integer&gt;;

Q2) What is included in a linked list node?

I a reference to its neighboring nodes

II an array reference

III a data element

A) I

B) II

C) II and III

D) I and III

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) If we want a create a doubly-linked list data structure so that we can move from a node to the next node as well as to a previous node we need to add a previous reference to the Node class. Each such DNode (doubly-linked Node) will have a data portion and two DNode references, next and previous. How many references need to be updated when we remove a node from the beginning of a list with many nodes? Consider the first reference and neighboring node(s).

A) 1

B) 2

C) 3

D) 4

Q2) Suppose we maintain a linked list of length n in sorted order. What would be the big-Oh notation for the add operation?

A) O(1)

B) O(n)

C) O(n log<sub>2</sub><sub> </sub>n)

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

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

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) The height h of a completely filled binary tree with n nodes is ____.

A) h = log2(n) - 1

B) h = log2(n) + 1

C) h = log2(n - 1)

D) h = log2(n + 1)

Q2) In a binary search tree, where the root node data value = 45, what do we know about the values of all the descendants in the right subtree of the root?

A) the root's right child value > 45, but the left child of the root's right child key is < 45

B) some values will be > 45, but there may be a few values < 45

C) approximately half the values are < 45, the other half are > 45

D) all will be > 45

Q3) If the child references of a binary tree node are both null, the node is ____.

A) a root node

B) a leaf node

C) a parent node

D) an interior node

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) Consider the following code snippet:

Public static &lt;T&gt; void fun(T[] t) { . . . }

Erasure by the compiler of method fun will generate which result?

A) public static &lt;T&gt; void fun(Object[] t) { . . . }

B) public static &lt;Object&gt; void fun(Object t) { . . . }

C) public static void fun(Object[] t) { . . . }

D) public static void fun(Object t) { . . . }

Q2) Which of the following statements about the Java virtual machine is correct?

A) The Java virtual machine always replaces type parameters with their upper bounds.

B) The Java virtual machine always replaces type parameters with their lower bounds.

C) The Java virtual machine always replaces type parameters with type Object.

D) The Java virtual machine replaces type parameters with their bounds or with type Object.

Q3) What does it mean when the syntax ? extends D is used?

A) Any superclass of D may be used.

B) Any subclass of D may be used.

C) Any subclass or superclass of D may be used.

D) This indicates a wildcard with an upper bound

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

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) The two IO classes used for serialization are _______ and ________.

A) Reader, Writer

B) ObjectInputStream, ObjectOutputStream

C) Scanner, PrintWriter

D) FileReader, FileWriter

Q2) The ____ class is used when writing text files.

A) PrintWriter

B) InputStream

C) JFileChooser

D) Serializable

Q3) Which is an advantage of storing numbers in binary format?

I fast access

II less storage needed

III easy to read in a text editor

A) I

B) III

C) I and II

D) I and III

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) The ________ method stops the current thread for a given number of milliseconds.

A) run

B) await

C) sleep

D) delay

Q2) Which phrase best describes the purpose of a lock used in an object in one or more of its methods?

A) increased sharing

B) mutual exclusion

C) speed increase

D) privacy protection

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

A) start

B) main

C) run

D) init

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) 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) What are among the most important pieces of information that must be included in an IP packet?

I. The Internet address of the recipient

II. The URL of the recipient

III. The Internet address of the sender

IV. The port number of the sender

A) I, III, and IV

B) I, II, and III

C) II, III, and IV

D) I, II, III, and IV

Q3) A(n) ____ is a pointer to an information resource on the World Wide Web.

A) URL

B) socket

C) IP address

D) domain name

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) The following command will compile a Java program called TestDB:

A) java TestDB.class

B) java TestDB.java

C) javac TestDB.java

D) javac TestDB.class

Q2) What is wrong with the following statement?

Boolean result = statement.execute("SELECT * from emp WHERE empNum = '?'");

A) boolean should be ResultSet

B) execute should be executeQuery

C) execute should be prepareStatement

D) \(?\) should be an integer

Q3) Oracle 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 kind of object do you need to create a new, empty XML document?

A) DocumentBuilder

B) newBuilder

C) newInstance

D) newDocumentBuilder

Q2) Using the grammar notation in your textbook, the expression &lt;article&gt; ::= a | the means:

A) "article must be equal to a and the"

B) "article can be replaced with a or the"

C) "article can be replaced with a and the"

D) "article cannot be equal a or the"

Q3) Which of the following statements is correct?

A) Elements cannot have attributes.

B) An XML document starts out with an HTML declaration and contains elements and text.

C) An element must contain text or elements, not both.

D) An attribute is appropriate only if it tells something about the data but is not part of the data itself.

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

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

A) A server with a JSF container such as GlassFish manages a pool of database connections.

B) JSF tags use XML syntax but the / before the closing angle bracket is not required.

C) JSF tags are case insensitive.

D) A JSF page cannot contain XML tags.

Q2) In JSF, button groups and ____ require that you specify two properties: the collection of possible choices and the actual choice.

A) menus

B) cookies

C) images

D) text areas

Q3) What does the second period in the following command denote?

Jar cvf time.war .

A) The root directory.

B) The parent directory

C) The current directory

D) The jar command directory

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
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
Object-Oriented Programming Final Exam - 2169 Verified Questions by Quizplus - Issuu