Object-Oriented Programming Exam Preparation Guide - 2169 Verified Questions

Page 1


Object-Oriented Programming Exam Preparation Guide

Course Introduction

Object-Oriented Programming introduces students to the fundamental principles and techniques of the object-oriented paradigm, emphasizing concepts such as classes, objects, encapsulation, inheritance, and polymorphism. Through hands-on programming assignments, students learn how to design, implement, and test robust and reusable software components. The course also explores topics like abstraction, code organization, and software maintainability, using popular object-oriented programming languages such as Java or C++. By the end, students will be equipped with the skills to solve complex problems using object-oriented solutions, laying a strong foundation for advanced 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) Which of the following statements is true with respect to the main method in Java?

A) The opening and closing parentheses after the method name main are optional.

B) A semicolon is required after the statement public static void main()

C) A semicolon is required after the closing curly braces in the main method.

D) Every Java application must have a main method.

Answer: D

Q2) What kind of error is created by the following code snippet? System.outt.println("Hello");

A) No error: the code is correct

B) Logic error: the program will run until it comes to this statement

C) Syntax error: the program will not compile

D) Exception: the statement will generate an exception

Answer: C

Q3) The Java statement public static void main(String[] args) declares a:

A) class

B) variable

C) constant

D) method

Answer: D

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

Public static void main(String[] args){

{ String str1;

Str1 = "I LOVE MY COUNTRY";

String str2 = str1.substring(4, 9); System.out.println(str2);

}

A) I LOV

B) OVE M

C) V

D) VE MY

Answer: D

Q2) Which one of the following reserved words is used in Java to represent a value without a fractional part?

A) integer

B) int

C) Int

D) Float Answer: B

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

Page 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) Assuming that a user enters 15 as input, what is the output of the following code snippet?

Scanner in = new Scanner(System.in); System.out.print("Please enter a number: "); Int number = in.nextInt(); If (number > 20)

{ System.out.println("The number is LARGE!");

} Else

{ System.out.println("The number is SMALL!");

}

A) There is no output due to compilation errors.

B) The number is LARGE!

C) The number is SMALL!

D) The number is LARGE! The number is SMALL!

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) Which of the following activities can be simulated using a computer?

I. Waiting time in a line at a restaurant

II. Tossing a coin

III. Shuffling cards for a card game

A) I only

B) II only

C) I and II only

D) I, II, and III

Q2) What is the output of the following code snippet?

Int counter = 1; For (double i = 0.01; i <= 1.0; i = i + 0.01)

{ Counter++;

} System.out.println(counter);

A) 100

B) 49.50

C) 60.5

D) 10

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) Which of the following options describes the process of stepwise refinement?

I. Using arguments to pass information to a method

II. Using unit tests to test the behavior of methods

III. Decomposing complex tasks into simpler ones

A) I

B) II

C) III

D) I, II, and III

Q2) You need to write a method that calculates the volume for a shape, which depends on the shape's length, width, and height. What should be the parameter variables and their data types for this method?

A) double length, double height

B) double length

C) double length, double height, String depth

D) double width, double length, double height

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) Which statement is true about the code snippet below?

ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;(); Names.add("John"); Names.add("Jerry");

ArrayList&lt;String&gt; friends = new ArrayList&lt;String&gt;(names); Friends.add("Harry");

A) The final size of names is 2; the final size of friends is 3

B) The final size of names is 3; the final size of friends is 2

C) The final size of names is 3; the final size of friends is 3

D) Compilation error

Q2) It may be necessary to "grow" an array when reading inputs because

A) the number of inputs may not be known in advance.

B) arrays in Java must be resized after every 100 elements.

C) arrays are based on powers of two.

D) the only alternative is a bounds exception.

Q3) How many elements can be stored in a two-dimensional 5 by 6 array?

A) 5

B) 6

C) 11

D) 30

To view all questions and flashcards with answers, click on the resource link above. Page 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) Which Java class implements a file dialog box for selecting a file by a program with a graphical user interface?

A) JOptionPane

B) JFileOption

C) JFilePane

D) JFileChooser

Q2) Consider the following code snippet: System.out.printf("%-12s%8.2f",description,totalPrice); Which of the following statements is correct?

A) This code will produce 2 columns, with the description field left justified and the totalPrice field right justified.

B) This code will produce 2 columns, with the description field right justified and the totalPrice field right justified.

C) This code will produce 2 columns, with the description field right justified and the totalPrice field left justified.

D) This code will produce 2 columns, with the description field left justified and the totalPrice field left justified.

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

A) An instance method should always be declared as public.

B) An instance method should always be declared as private.

C) An instance method should be declared as public only if it is a helper method.

D) An instance method should be declared as private only if it is a helper method.

Q2) You have created a Motorcycle class which has a constructor with no parameters.

Which of the following statements will construct an object of this class?

A) Motorcycle myBike;

B) Motorcycle myBike = new Motorcycle();

C) myBike.new(Motorcycle);

D) Motorcycle.new(myBike);

Q3) The ____ operator is used to construct an object from a class.

A) add

B) create

C) new

D) construct

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

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 an interface is true?

A) An interface has methods and instance variables.

B) An interface has methods but no instance variables.

C) An interface has neither methods nor instance variables.

D) An interface has instance variables but no methods.

Q2) The ____ reserved word in a class definition ensures that subclasses cannot be created from this class.

A) abstract

B) anonymous

C) final

D) static

Q3) Which of the following statements about classes is true?

A) You can create an object from a concrete class, but not from an abstract class.

B) You can create an object from an abstract class, but not from a concrete class.

C) You cannot have an object reference whose type is an abstract class.

D) You cannot create subclasses from abstract classes.

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

11

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 events and graphical user interface programs is true?

A) Your program must indicate the specific types of events to which it wishes to respond.

B) Your program will automatically receive notifications about all events that have occurred.

C) Your program must respond to notifications of all types of events that are sent to it while it is running.

D) Your program must override the default methods to handle events.

Q2) When drawing complex shapes, provide a(n) ____ to set the position of the shape.

A) constructor

B) viewer

C) component

D) frame

Q3) Which container is used to group multiple user-interface components together?

A) text area

B) table

C) panel

D) rectangle

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) Which of the following adds a border to the following panel?

JPanel panel = new JPanel();

A) panel.addEtchedBorder();

B) panel.addBorder(new EtchedBorder());

C) panel.add(new EtchedBorder());

D) panel.setBorder(new EtchedBorder());

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

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

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

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) In general, you need ____ when an object needs to remember another object between method calls.

A) inheritance

B) aggregation

C) association

D) an interface implementation

Q2) Which of the following would be an appropriate name for a game-related class?

A) FinalizeLevelOne

B) InitialLevel

C) ResetTheCurrentLevel

D) AscendToFinalLevel

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

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) Complete the code for the myFactorial recursive method shown below, which is intended to compute the factorial of the value passed to the method: Public int myFactorial(int anInteger)

{ { Return 1; } Else

{ Return(anInteger * myFactorial(anInteger - 1)); } }

A) if (anInteger == 1)

B) if ((anInteger - 1) == 1)

C) if (anInteger * (anInteger - 1) == 1)

D) if (myFactorial(anInteger) == 1)

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 sorts in the textbook can be characterized by the fact that even in the worst case the running time will be O(n log(n)))?

I quicksort

II selection sort

III merge sort

A) I

B) II

C) III

D) I and III

Q2) In the textbook, we determined that the merge method requires a total of 5n visits. We found that the number of visits required to sort an array of n elements is T(n) = T(n / 2) + T(n / 2) + 5n. What does T(n / 2) describe?

A) the total number of visits to merge sort an array of n elements

B) half the number of visits to merge sort an array of n elements

C) the total number of visits to merge sort an array of n / 2 elements

D) half the number of visits to merge sort an array of n / 2 elements

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) You intend to use a hash set with your own object class. Which of the following statements is NOT correct?

A) You do not have to do anything additional. You can use the hashCode function of the Object class.

B) You can create your own function to compute a hashCode value.

C) You can override the hashCode method in the Object class to provide your own hashCode method.

D) Your class's hashCode method does not need to be compatible with its equals method.

Q2) Assume that you have declared a stack named myStack to hold String elements. Which of the following statements will correctly add an element to myStack?

A) myStack.put("apple");

B) myStack.addItem("apple");

C) myStack.push("apple");

D) myStack.insert("apple");

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) Using the textbook's implementation of a linked list, which of the following statements about managing nodes within a linked list using an iterator is correct?

A) The node that will be removed is the node pointed to by the position.next reference.

B) The set method can be called immediately after adding a new node using the add method.

C) The set method can be called immediately after removing an existing node using the remove method.

D) The position reference must be updated when a new node is added.

Q2) Which of the following algorithms would be efficiently executed on a LinkedList?

A) tracking paths in a maze

B) binary search

C) remove first n / 2 elements from a list of n elements

D) read n / 2 elements in random order from a list of n elements

Q3) What is never present in a static inner class?

A) an outer-class reference.

B) the this reference to itself.

C) static properties.

D) static methods.

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) A binary search tree is made up of a collection of nodes organized with smaller data values on the left and greater values on the right relative to any node. Which of the following Node references must be instance variables of any implementation of a Node class?

I root

II left III right

A) I

B) II and III

C) I and II

D) I, II and III

Q2) What is the complexity of removing an element from a heap?

A) O(1)

B) O(log (n))

C) O(n log (n))

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

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

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 class LinkedList&lt;E&gt; {

Private static E defaultValue; //Line 1

Public void add(E value, int n) { . . . } //Line 2

Private class Node { public String data; public Node next;)//Line 3 )

What is wrong with this code?

A) Cannot declare the variable defaultValue as static.

B) Cannot pass a generic type as an argument to a method as shown.

C) Cannot have an inner class in a generic class as shown.

D) Cannot declare the variable defaultValue as a generic data type.

Q2) Which of the following statements about using generic programming is NOT correct?

A) Using type parameters makes generic code safer.

B) Using type parameters makes generic code easier to read and understand.

C) Using type parameters will potentially avoid some class cast exceptions that may occur when using collections without type parameters.

D) Type parameters cannot be used with interfaces.

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) To read text data from a disk file, you should create a(n) ____________________ object.

A) Scanner

B) PrintWriter

C) InputStream

D) OutputStream

Q2) Which method moves the file pointer in a RandomAccessFile?

A) seek

B) length

C) getFilePointer

D) close

Q3) If serializing object obj requires 12 bytes, how many bytes are required to serialize obj 3 times?

A) 12 bytes plus 3 serial numbers of obj

B) 36 bytes

C) 12 bytes

D) 12 bytes plus 2 serial numbers of obj

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 GUI should be responsive to the user. If a GUI interaction starts a time-consuming task, the GUI may not be responsive to the user until the task completes. Which approach would make the GUI responsive under these circumstances?

A) As you run the task, break and check for events.

B) Ask the user if she is sure she wants to run the task.

C) Run the task in a separate thread.

D) Disable the GUI during the task.

Q2) The Runnable interface has a single method called ____________.

A) run

B) start

C) sleep

D) wait

Q3) Which method do you call to make a thread ineligible to run on the CPU for a set number of milliseconds?

A) start

B) wait

C) await

D) sleep

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

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) A thread dies ______________

A) when the client quits or disconnects.

B) when the run method exits.

C) when the client quits or disconnects and/or when the run method exits.

D) the thread runs forever in the background.

Q2) The Java library provides a _________ class that can take care of the socket connection to a web server.

A) SocketConnection

B) ServerConnection

C) ClientConnection

D) URLConnection

Q3) Each IP ____ is delivered separately, and each one that is a part of the same transmission can take different routes through the Internet.

A) packet

B) socket

C) address

D) port number

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) An example of a production-quality database is:

A) Oracle

B) MS Access

C) Apache Derby

D) Powerbuilder

Q2) A ____________ is a reference to a primary key in a linked table.

A) foreign key

B) primary key

C) column headers

D) data type

Q3) The ___ symbol in the query string denotes variables that you fill in when you make an actual query

A) \(?\)

B) *

C) !

D) ::

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) Where is the newDocumentBuilder method?

A) In the DocumentBuilder class.

B) In the DocumentFactoryBuilder class.

C) In the DocumentFactory class.

D) In the DocumentBuilderFactory class.

Q2) How can a DTD specify that a course child element in a semester element is optional?

A) <!ELEMENT semester (class?, course)>

B) <!ELEMENT semester (class, course) />

C) <!ELEMENT semester (class, course?)>

D) <!ELEMENT semester (class, course*)>

Q3) To insert text, you need the _________methods.

A) insertElement and setElement

B) createNode and insertChild

C) createTextNode and appendChild

D) insertTextNode and insertChild

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) JSF pages define the ___________ of a web application.

A) swings

B) presentation logic

C) business logic

D) value expressions

Q2) One of the corresponding methods for a JavaBean property called city is:

A) getcity()

B) getCity()

C) GetCity()

D) Getcity()

Q3) What does the value expression timeBean.time do?

A) Sets the timeBean.time instance variable.

B) Calls the timeBean.setTime method

C) Calls the timeBean.getTime method

D) Creates an input field called time.

Q4) The expression #{timeBean.time} is called a ____________.

A) bean expression

B) time expression

C) value expression

D) managed bean

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
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.