Object-Oriented Programming Exam Practice Tests - 981 Verified Questions

Page 1


Object-Oriented Programming Exam Practice Tests

Course Introduction

Object-Oriented Programming introduces the fundamental concepts and principles of object-oriented development using programming languages such as Java or C++. Topics covered include classes and objects, encapsulation, inheritance, polymorphism, and abstraction, as well as design considerations for building modular, reusable, and maintainable software. Students will learn how to model real-world problems using objects, implement solutions using object-oriented techniques, and understand the advantages of object-oriented design in software engineering. Practical exercises and projects reinforce theoretical concepts and help develop proficiency in writing effective, efficient, and robust object-oriented code.

Recommended Textbook

Starting Out with Java From Control Structures through Data Structures 2nd Edition by Tony Gaddis

Available Study Resources on Quizplus

22 Chapters

981 Verified Questions

981 Flashcards

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

Chapter 1: Introduction to Computers and Java

Available Study Resources on Quizplus for this Chatper

42 Verified Questions

42 Flashcards

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

Sample Questions

Q1) A byte is a collection of:

A) Four bits

B) Six bits

C) Eight bits

D) A dollar Answer: C

Q2) Java source files end with the .class extension.

A)True

B)False

Answer: False

Q3) Because Java byte code is the same on all computers,compiled Java programs

A) Must be re-compiled for each different machine it is run on

B) Cannot run on Linux systems

C) Are non-existent

D) Are highly portable

Answer: D

Q4) Each byte is assigned a unique number known as an address.

A)True

B)False

Answer: True

Page 3

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

Chapter 2: Java Fundamentals

Available Study Resources on Quizplus for this Chatper

53 Verified Questions

53 Flashcards

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

Sample Questions

Q1) The primitive data types only allow a(n)_____ to hold a single value.

A) variable

B) object

C) class

D) literal

Answer: A

Q2) Which of the following is not a rule that must be followed when naming identifiers?

A) The first character must be one of the letters a-z,A-Z,and underscore or a dollar sign.

B) Identifiers can contain spaces.

C) Uppercase and lowercase characters are distinct.

D) After the first character,you may use the letters a-z,A-Z,the underscore,a dollar sign,or digits 0-9.

Answer: B

Q3) Assuming that pay has been declared a double,the following statement is valid. pay = 2,583.44;

A)True

B)False

Answer: False

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

4

Chapter 3: Decision Structures

Available Study Resources on Quizplus for this Chatper

52 Verified Questions

52 Flashcards

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

Sample Questions

Q1) What is the value of ans after the following code has been executed? int x = 35; Int y = 20,ans = 80; If (x < y);

Ans += y;

A) 80

B) 100

C) 35

D) 55

Answer: B

Q2) In a switch statement,if two different values for the CaseExpression would result in the same code being executed,you must have two copies of the code,one after each CaseExpression.

A)True

B)False

Answer: False

Q3) A local variable's scope always ends at the closing brace of the block of code in which it is declared.

A)True

B)False

Answer: True

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

Chapter 4: Loops and Files

Available Study Resources on Quizplus for this Chatper

48 Verified Questions

48 Flashcards

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

Sample Questions

Q1) The do-while loop must be terminated with a semicolon.

A)True

B)False

Q2) In the following code,what values could be read into number to terminate the while loop? Scanner keyboard = new Scanner(System.in); System.out.print("Enter a number: "); Int number = keyboard.nextInt(); While (number < 100 || number > 500)

{ System.out.print("Enter another number: "); Number = keyboard.nextInt();

}

A) Numbers less than 100

B) Numbers greater than 500

C) Numbers in the range 100 - 499

D) Numbers in the range 100 - 500

Q3) The do-while loop is a pre-test loop.

A)True

B)False

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

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Which of the following is not part of a method call?

A) method name

B) return type

C) parentheses

D) all of the above are part of a method call

Q2) Constants,variables,and the values of expressions may be passed as arguments to a method.

A)True

B)False

Q3) The expression in a return statement can be any expression that has a value.

A)True

B)False

Q4) Local variables

A) are hidden from other methods

B) may have the same name as local variables in other methods

C) lose the values stored in them between calls to the method in which the variable is declared

D) All of the above

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

Chapter 6: A First Look at Classes

Available Study Resources on Quizplus for this Chatper

49 Verified Questions

49 Flashcards

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

Sample Questions

Q1) The term "default constructor" is applied to the first constructor written by the author of a class.

A)True

B)False

Q2) A constructor

A) always accepts two arguments

B) has return type of void

C) has the same name as the class

D) always has an access specifier of private

Q3) The scope of a private instance field is

A) the instance methods of the same class

B) inside the class,but not inside any method

C) inside the parentheses of a method header

D) the method in which they are defined

Q4) In UML diagrams,this symbol indicates that a member is public.

A) /

B) @

C)D) +

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

Chapter 7: A First Look at Gui Applications

Available Study Resources on Quizplus for this Chatper

49 Verified Questions

49 Flashcards

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

Sample Questions

Q1) The minimize button,maximize button,and close button on a window are sometimes referred to as

A) operations buttons

B) sizing buttons

C) decorations

D) display buttons

Q2) When this is the argument passed to the JFrame class's setDefaultCloseOperation()method,the application is hidden,but not closed.

A) HIDE_ON_CLOSE

B) JFrame.HIDE_ON_CLOSE

C) JFrame.EXIT_ON_CLOSE

D) JFrame.HIDE_NOT_CLOSE

Q3) To use the Color class,which is used to set the foreground and background of various objects,use the following import statement

A) import java.swing;

B) import java.awt;

C) import java.awt.*;

D) import java.awt.event.*;

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

Chapter 8: Arrays and the Arraylist Class

Available Study Resources on Quizplus for this Chatper

52 Verified Questions

52 Flashcards

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

Sample Questions

Q1) Java limits the number of dimensions that an array may have to 15.

A)True

B)False

Q2) Which of the following is a correct method header for receiving a two-dimensional array as an argument?

A) public static void passArray(int[2])

B) public static void passArray(int [][])

C) public static void passArray(int[1][2])

D) public static void passArray(int[],int[])

Q3) You can use this ArrayList class method to insert an item at a specific location in an ArrayList.

A) insert

B) add

C) store

D) putItem

Q4) Java does not limit the number of dimensions that an array may have.

A)True

B)False

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

Chapter 9: A Second Look at Classes and Objects

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) If the following is from the method section of a UML diagram,which of the following statements is true? + add(object2:Stock): Stock

A) This is a private method named add that accepts and returns objects of the Stock class.

B) This is a private method named Stock that adds two objects.

C) This is a public method named add that accepts and returns references to objects in the Stock class.

D) This is a public method named Stock that adds two objects.

Q2) You can declare an enumerated data type inside of a method.

A)True

B)False

Q3) Enum constants have a toString method.

A)True

B)False

Q4) The names of the enum constants in an enumerated data type must be enclosed in quotation marks.

A)True

B)False

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

11

Chapter 10: Text Processing and More About Wrapper

Classes

Available Study Resources on Quizplus for this Chatper

49 Verified Questions

49 Flashcards

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

Sample Questions

Q1) To convert the string,str = "285.74" to a double,use the following statement.

A) double x = str;

B) double x = Double.parseDouble(str);

C) double x = Double.Double(str);

D) double x = str,Double.parseDouble;

Q2) What does the following statement do? Float number = new Float(8.8);

A) It creates a Float object

B) It initializes that object to 8.8

C) It assigns the object's address to the number variable

D) All of the above

Q3) Which of the following statements will print the maximum value a double variable may have?

A) System.out.println(MAX_VALUE);

B) System.out.println(double.MAX_VALUE);

C) System.out.println(Double.MAX_VALUE);

D) System.out.println(Double.MAXIMUM_VALUE);

Q4) The String class's valueOf()method accepts a string representation as an argument and returns its equivalent integer value.

A)True

B)False

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

Chapter 11: Inheritance

Available Study Resources on Quizplus for this Chatper

49 Verified Questions

49 Flashcards

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

Sample Questions

Q1) Look at the following code.Which line has an error? Line 1 public interface Interface1

Line 2 {

Line 3 int FIELDA = 55;

Line 4 public int methodA(double){}

Line 5 }

A) 1

B) 2

C) 3

D) 4

Q2) A protected member of a class may be directly accessed by

A) methods of the same class

B) methods of a subclass

C) methods in the same package

D) All of the above.

Q3) It is not possible for a superclass to call a subclass's method.

A)True

B)False

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

Page 13

Chapter 12: Exceptions and Advanced File Io

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) If a random access file contains a stream of characters,which of the following would you use to set the pointer on the fifth character?

A) file.seek(4);

B) file.seek(5);

C) file.seek(9);

D) file.seek(8);

Q2) If,within one try statement you want to have catch clauses of the following types,in which order should they appear in your program: (1)Exception (2)IllegalArgumentException (3)RuntimeException (4)Throwable

A) 1,2,3,4

B) 2,3,1,4

C) 4,1,3,2

D) 3,1,2,4

Q3) The call stack is an internal list of all the methods that are currently executing. A)True B)False

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

Chapter 13: Advanced Gui Applications

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) A label's preferred size is determined only by calling the setPreferredSize method.

A)True

B)False

Q2) The Dimension class is part of the

A) javax.swing.event package

B) java.awt.menu package

C) javax.swing package

D) java.awt package

Q3) When an item in a Jlist object is selected it generates a(n)

A) action listener event

B) action performed event

C) list selection listener event

D) list selection event

Q4) A menu system may consist of each of the following,except

A) check box menu item

B) combo box menu item

C) radio button menu item

D) menu item

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

Chapter 14: Applets and More

Available Study Resources on Quizplus for this Chatper

39 Verified Questions

39 Flashcards

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

Sample Questions

Q1) Which tag will produce largest text?

A) < h4 >Hello< /h4 >

B) < h3 >Hello< /h3 >

C) < h2 >Hello< /h2 >

D) < h1 >Hello< /h1 >

Q2) Hypertext can contain

A) a Java application program

B) exception methods

C) executable code

D) a link to another Web page

Q3) A mouse motion listener class can respond to:

A) The mouse button is clicked on

B) The mouse cursor exits a component's screen space

C) The mouse moved

D) The mouse button is released

Q4) The browser creates an instance of the applet class automatically.

A)True

B)False

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

Chapter 15: Recursion

Available Study Resources on Quizplus for this Chatper

34 Verified Questions

34 Flashcards

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

Sample Questions

Q1) Look at the following pseudocode algorithm. Algorithm gcd(x,y)

If (x < y)

Gcd (y,x)

Else

If (y = 0)

Return x

Else

Return gcd(y,x mod y)

End gcd

What is returned from gcd(60,24)?

A) 60

B) 24

C) 12

D) 66

Q2) Indirect recursion occurs when a method calls another method that in turn calls the first method.

A)True

B)False

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

Page 17

Chapter 16: Sorting, Searching, and Algorithm Analysis

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) The best way to measure the goodness of an algorithm is

A) to write a computer program that uses the algorithm and time its execution

B) to write a computer program that uses the algorithm and run it on the hardest and largest inputs

C) to look at its worst case and average case complexity functions

D) to look at the sum of its execution time and the space it uses

Q2) For a computational problem,the input size

A) is the number of times the program requests input from the user

B) is the number of loop iterations required to read the input

C) is the amount of memory needed to store the input

D) None of the above

Q3) Sequential Search is in the complexity class

A) O(1)

B) O(log n.

C) O(n.

D) O(n log n.

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

18

Chapter 17: Generics

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) A class is generic

A) if it is a subclass of the Object class

B) if it is a superclass of the Object class

C) if it has type parameters

D) if it has method parameters

Q2) The code

Public class MyClass< T > {

Public MyClass(){

T myObject = new T();

A) will not compile

B) compiles correctly,but causes a runtime exception when the program is executed

C) compiles and runs correctly,but is inefficient

D) compiles and runs correctly and efficiently

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

Chapter 18: Collections

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The ListIterator method that replaces an existing element with a new element is A) set

B) replace

C) overwrite

D) add

Q2) The enhanced for loop,when used on a collection,

A) is converted by the compiler to a traditional loop that uses an iterator

B) should be avoided because it incurs runtime overhead

C) throws an runtime exception

D) None of the above

Q3) Comparable

A) is a class that allows two objects to be compared

B) is an interface implemented by classes that need to impose a natural order on instance objects

C) is a library class method that is used by certain sorting packages

D) None of the above

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

Page 20

Chapter 19: Array-Based Lists

Available Study Resources on Quizplus for this Chatper

20 Verified Questions

20 Flashcards

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

Sample Questions

Q1) The E get(int index)method of the List interface should throw an exception if A) the index passed to it is negative

B) the index passed to it nonnegative

C) the index passed to it is negative or greater or equal to the size of the list

D) the index passed to is negative or greater than the size of the list

Q2) Assume an array-based list implemented by a class that uses the fields String [ ] list; int nElements;

to represent the array of elements,and the number of elements currently stored.Show the code for a method String remove(int index)that removes and returns the element at the given index.The method should throw an appropriately named exception if it cannot return the requested element.

Q3) The size of an array-based list such as ArrayList

A) is the number of bytes of memory that the list can hold

B) is the number of elements that are currently stored in the list

C) is the length of its internal array

D) None of the above

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

21

Chapter 20: Linked Lists

Available Study Resources on Quizplus for this Chatper

36 Verified Questions

36 Flashcards

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

Sample Questions

Q1) To remove a node X with index 1 or greater from a linked list, A) set a reference pred to the predecessor of the node you want to remove,and set the successor of pred to the successor of X B) decrease the index of the node to be removed by 1,and then set its reference to null C) first store the value of the element in X in a safe place,then set its reference to null D) None of the above

Q2) In Java,the first node in a list has index A) -1

B) 0

C) 1

D) 2

Q3) A list in which each stored element is associated with a reference to its successor is called

A) an array list

B) a map

C) a linked list

D) None of the above

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

Chapter 21: Stacks and Queues

Available Study Resources on Quizplus for this Chatper

36 Verified Questions

36 Flashcards

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

Sample Questions

Q1) A stack is a container that allows elements to be stored and removed

A) in a last-in-first-out fashion

B) in a first-in-first-out fashion

C) last-in-last-out fashion

D) according to priority

Q2) The stack pop operation

A) removes all items currently on the stack

B) extracts one element from the stack and returns it

C) removes from the stack the number of elements specified by its integer parameter

D) does not exist: There is no such stack operation

Q3) In a list implementation of a queue,the end of the list from which elements are removed is called

A) the front of the queue

B) the rear of the queue

C) the top of the queue

D) the bottom of the queue

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

Chapter 22: Binary Trees, Avl Trees, and Priority Queues

Available Study Resources on Quizplus for this Chatper

45 Verified Questions

45 Flashcards

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

Sample Questions

Q1) The order condition that characterizes a heap states that

A) at each node X,any element stored in a child of X must be greater than the element stored at X

B) at each node X,any element stored in a left child of X must be less than the element stored at X,and any element stored in right child must be greater than the element stored at X

C) an inorder traversal of the heap's binary tree must yield a sorted sequence

D) None of the above

Q2) A sorting algorithm based on a priority queue is

A) quicksort

B) insertion sort

C) bubble sort

D) heap sort

Q3) Adding all items from a list to a certain data structure and then removing them one at a time yields a sorted version of the list.The data structure is a

A) priority queue

B) binary search tree

C) complete binary tree

D) binary sort tree

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

Page 24

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.