Skip to main content

Object-Oriented Programming Test Bank - 981 Verified Questions

Page 1


Object-Oriented Programming Test Bank

Course Introduction

Object-Oriented Programming introduces the fundamental principles and techniques of designing and implementing software using the object-oriented paradigm. The course covers key concepts such as classes, objects, inheritance, encapsulation, polymorphism, and abstraction, emphasizing the creation of modular, reusable, and maintainable code. Students will develop proficiency in using object-oriented programming languages to solve real-world problems, design class hierarchies, and apply best practices in software development. Practical assignments and projects reinforce theoretical knowledge, preparing students to tackle complex software engineering tasks using object-oriented approaches.

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) Java source files end with the .class extension.

A)True

B)False

Answer: False

Q2) The major components of a typical computer system consist of:

A) The CPU

B) Input/output devices

C) Main memory

D) Secondary storage devices

E) All of the above

Answer: E

Q3) Which of the following will compile a program called ReadIt?

A) java ReadIt.java

B) java ReadIt.javac

C) javac ReadIt.java

D) javac ReadIt.javac

Answer: C

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

Page 3

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) What will be displayed as a result of executing the following code? int x = 5,y = 20;

X += 32;

Y /= 4;

System.out.println("x = " + x + ",y = " + y);

A) x = 32,y = 4

B) x = 9,y = 52

C) x = 37,y = 5

D) x = 160,y = 80

Answer: C

Q2) Both character literals and string literals can be assigned to a char variable.

A)True

B)False

Answer: False

Q3) This is a named storage location in the computer's memory.

A) Literal

B) Constant

C) Variable

D) Operator

Answer: C

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

Page 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 will be printed when the following code is executed? double x = 45678.259; DecimalFormat formatter = New DecimalFormat("#,###,##0.00"); System.out.println(formatter.format(x));

A) 45678.259

B) 0,045,678.26

C) 45,678.26

D) 45,678.3

Answer: C

Q2) What will be the value of charges after the following code is executed? double charges,rate = 7.00; Int time = 180;

Charges = time < = 119 ? rate * 2 : Time / 60.0 * rate;

A) 7.00

B) 14.00

C) 21.00

D) 28.00

Answer: C

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) What will be the value of x after the following code is executed? int x,y = 4,z = 6;

X = (y++)* (++z);

A) 24

B) 28

C) 30

D) 35

Q2) A loop that repeats a specific number of times is known as a(n)

A) sentinel loop

B) conditional loop

C) counter-controlled loop

D) infinite loop

Q3) In all but rare cases,loops must contain within themselves

A) arithmetic statements

B) if statements

C) a way to terminate

D) nested loops

Q4) 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) What is wrong with the following method call? displayValue (double x);

A) There is nothing wrong with the statement.

B) displayValue will not accept a parameter.

C) Do not include the data type in the method call.

D) x should be a String.

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

A)True

B)False

Q3) If method A calls method B,and method B calls method C,and method C calls method D,when method D finishes,what happens?

A) control is returned to method A

B) control is returned to method B

C) control is returned to method C

D) the program terminates

Q4) No statement outside the method in which a parameter variable is declared can access the parameter by its name.

A)True

B)False

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

Q2) A class specifies the ________ and ________ that a particular type of object has.

A) relationships;methods

B) fields;object names

C) fields;methods

D) relationships;object names

Q3) True/False: The term "no-arg constructor" is applied to any constructor that does not accept arguments.

A)True

B)False

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

A) *

B) #

C) -

D) +

Page 8

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

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) This is a graphic image that is displayed while an application loads into memory and starts up.

A) The Java 6 trademark screen

B) Memory usage screen

C) Blue screen of death

D) Splash screen

Q2) In a Swing application,you create a frame object from the

A) Jlabel class

B) JFrame class

C) Jpanel class

D) AbstractButton class

Q3) You must use the statement import java.swing.*;in order to use the ItemListener interface.

A)True

B)False

Q4) When a component is added to a region in the BorderLayout manager,

A) the component retains its original size

B) it results in a compile time error,if it is too large

C) the component is stretched so it fills up the entire region

D) the region is resized to fit the component

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

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) The String[] args parameter in the main method header allows the program to receive arguments from the operating system command-line.

A)True

B)False

Q2) What is the value of scores[2][3] in the following array? int [] [] scores = { {88,80,79,92},{75,84,93,80}, {98,95,92,94},{91,84,88,96} };

A) 94

B) 84

C) 93

D) 95

Q3) If a[] and b[] are two integer arrays,the expression a == b compares the array contents.

A)True

B)False

Q4) When an array of objects is declared,but not initialized,the array values are set to null.

A)True

B)False

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

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) The names of the enum constants in an enumerated data type must be enclosed in quotation marks.

A)True

B)False

Q3) The JVM periodically performs this process to remove unreferenced objects from memory.

A) memory sweeping

B) garbage collection

C) memory shuffling

D) system restore

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

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) In a string that contains a series of words or other items of data separated by spaces or other characters,the programming term for the spaces or other characters is A) token

B) delimiter

C) buffer

D) separator

Q2) To use the StringTokenizer class you must have the following import statement. A) import java.util.StringTokenizer; B) import java.util.String; C) import java.StringTokenizer; D) import java.String;

Q3) In a string that contains a series of words or other items of data separated by spaces or other characters,the programming term for the data items is A) token

B) delimiter

C) buffer

D) separator

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) Which of the following statements correctly specifies three interfaces:

A) public class ClassA implements Interface1,Interface2,Interface3

B) public class ClassA implements [Interface1,Interface2,Interface3]

C) public class ClassA implements (Interface1,Interface2,Interface3)

D) public class ClassA implements Interface1 Interface2 Interface3

Q3) All fields declared in an interface

A) are final and static

B) have protected access

C) must be initialized in the class implementing the interface

D) have private access

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) Look at the following code: FileInputStream fstream = New FileInputStream("MyInfo.dat");

DataInputStream inputFile = New DataInputStream(fstream); This code can also be written as:

A) FileInputStream inputFile = New FileInputStream(new DataInputStream("MyInfo.dat"));

B) DataInputStream inputFile = New DataInputStream(new FileInputStream("MyInfo.dat"));

C) FileInputStream fstream = New DataInputStream("InputFile.txt");

D) DataInputStream inputFile = New DataInputStream("InputFile.txt");

Q2) An exception's default error message can be retrieved using this method.

A) getMessage()

B) getErrorMessage()

C) getDefaultMessage()

D) getDefaultErrorMessage()

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

14

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) Which of the following statements creates a horizontal slider component with a minimum value of 0,a maximum value of 50,and an initial value of 25?

A) JSlider slider = New JSlider(0,50,25,JSlider.HORIZONTAL);

B) JSlider slider = New JSlider(JSlider.HORIZONTAL,0,50,25);

C) JSlider slider = New JSlider(JSlider.HORIZONTAL,25,0,50);

D) JSlider slider = New JSlider(JSlider.HORIZONTAL,50,0,25);

Q2) When you write a change listener class method for a slider,it must implement the ChangeListener interface which is in the javax.swing.event package.

A)True B)False

Q3) You can create a label with an image,or with both an image and text.

A)True B)False

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) The delay parameter in the Timer constructor is the amount of time between action events,measured in microseconds.

A)True

B)False

Q2) The play method will load and play a sound file once,then release it for garbage collection.The getAudioClip method will load the sound file and may assign the location of the sound file to a variable so it may be invoked many times.

A)True

B)False

Q3) If a frame component is 200 pixels wide and 300 pixels high,the lower,left-hand corner has (X,Y)coordinates of

A) (0,299)

B) (0,300)

C) (200,0)

D) (0,0)

Q4) The Applet class requires that you write a constructor to create an object of the class.

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) Like a loop,a recursive method must have

A) a counter.

B) some way to control the number of times it repeats itself.

C) a return statement.

D) a predetermined number of times it will execute before terminating.

Q2) The depth of recursion is

A) the number of times that a method calls itself.

B) the value returned from the last recursive call.

C) the value that will terminate the recursive calls.

D) There is no such term.

Q3) The number of times that a method calls itself is known as the

A) height of recursion

B) depth of recursion

C) width of recursion

D) length of recursion

Q4) Which of the following problems cannot be programmed recursively?

A) Towers of Hanoi

B) Summing a range of array elements

C) Finding the greatest common divisor

D) All of the above can be programmed recursively

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 following implementation of QuickSort

Static void doQuickSort(int array[ ],int start,int end){

Int pivotPoint;

PivotPoint = partition(array,start,end);

DoQuickSort(array,pivot+1,end);

DoQuickSort(array,start,pivot-1);

}

A) will correctly sort the array if the partition method is written correctly B) will give incorrect results because the two recursive calls are called in the wrong order C) will sort the array in descending rather than ascending order D) will be terminated by the system for making too many recursive calls

Q2) Let F be an algorithm with complexity function f(n),and let G be an algorithm with complexity function g(n).If the ratio f(n)/g(n)converges to infinity as n increases to infinity,then

A) the algorithm F is asymptotically faster than G

B) the algorithm G is asymptotically faster than F

C) the two algorithms are asymptotically equivalent in efficiency

D) None of the above

To view all questions and flashcards with answers, click on the resource link above. Page 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) Let Point< T > be a generic type.We want to write a method that takes as parameter Point objects whose type parameter is the Number class,or any superclass of Number.We can do this by writing

A) Point< Number >

B) Point< ? super Number >

C) Point< ? extends Number >

D) Point< ? sub Number >

Q2) Suppose that Point< T > is a generic type,and that we have a method of the form Void printPoint(Point< ? > p){

// Code not shown

}

A) We will get a compiler error unless we declare the method abstract

B) We may pass any object as an actual parameter for p

C) We may only only pass Number objects as parameters for p

D) None of the above

Q3) Which of the following generic type notations uses a wildcard?

A) Point< W >

B) Point< T extends Number >

C) Point< T super Integer >

D) Point< ? >

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) An object that can compare two other objects and determine whether one is greater than,less than,or equal to the other is a

A) Comparator

B) Comparable

C) Sorter

D) Sequencer

Q2) Which of the following is true of a HashSet object?

A) Increasing the capacity of the HashSet usually has no effect on the number of collisions

B) The time required to add an element,or search for an element,is unaffected by the number of collisions

C) The time required to add an element,or search for an element,decreases as the number of collisions increases

D) The time required to add an element,or search for an element,increases as the number of collisions increases

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

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) 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 constructor that creates a list with a default capacity of 100.

Q2) A constructor for an array-based list takes an integer parameter,to be used as the capacity of the internal array of the list.Which exception should the constructor throw if its parameter is zero or negative?

A) IllegalArgumentException

B) IllegalStateException

C) RuntimeException

D) NullPointerException

Q3) The boolean contains(E element)method searches a ArrayList for a given element.A correct and efficient implementation of this method

A) throws an exception if the element is not found in the list

B) uses binary search to locate the element

C) uses sequential search to locate the element

D) returns 0 if the element is not found in the list

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

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) A doubly linked list makes it easy to

A) move from any node to its successor,and from any node to its predecessor

B) skip two nodes at a time when moving forward through the list

C) skip two nodes at a time when moving backward through the list

D) to create a second copy of the linked list

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

A) -1

B) 0

C) 1

D) 2

Q3) When using recursion on linked lists

A) the linked list class is subclassed,and then the recursive method overrides a method of the same name in the list class

B) the recursive method should be one of the methods specified in the List interface

C) the recursive method should be made private,and should be called by a public non-recursive method

D) the recursive method should not call itself outside of its base case

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

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) The stack class provided by the Java Collections Framework

A) can be used to hold values of any type

B) can be used to create stacks of int

C) cannot be used to instantiate a stack of int,or of any primitive type

D) is not efficient,so its use is not recommended

Q2) In a list implementation of a stack,the end of the list at which elements are added and removed is called

A) the active end of the stack

B) the head of the stack

C) the top of the stack

D) the bottom of the stack

Q3) The stack peek operation

A) checks a stack to see if there are any elements in it

B) removes and returns an item from the stack

C) returns the item at the top of the stack,but does not remove it

D) adds a single item to the stack

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) A binary tree with just one node has height A) -1

B) 0

C) 1

D) None of the above

Q2) Let X be a node in a binary tree.The collection of all descendants of X A) form a binary tree called the subtree rooted at X B) form the left subtre of X C) form the right subtree of X

D) None of the above

Q3) A complete binary tree with N nodes may be stored in an array A of length N by storing the root at A[0],and then storing in successive array locations the nodes of the tree in increasing order of the level of nodes.If nodes in the same level are stored in left to right order,then the right child of the node stored at A[k] will be stored at A) A[k/2]

B) A[2k]

C) A[2k+1]

D) A[2k+2]

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

24

Turn static files into dynamic content formats.

Create a flipbook
Object-Oriented Programming Test Bank - 981 Verified Questions by Quizplus - Issuu