Object-Oriented Programming Practice Questions - 891 Verified Questions

Page 1


Object-Oriented Programming Practice Questions

Course Introduction

Object-Oriented Programming introduces students to the fundamental concepts and techniques of designing and implementing software using the object-oriented paradigm. The course covers key principles such as abstraction, encapsulation, inheritance, and polymorphism, enabling students to organize and structure code for modularity, reusability, and maintainability. Through hands-on programming exercises and projects, learners gain proficiency in using classes, objects, methods, and interfaces, typically within languages like Java or C++. The course emphasizes problem-solving, debugging, and the application of object-oriented design patterns to build robust and scalable applications.

Recommended Textbook

Starting Out with C++ from Control Structures to Objects 8th Edition by Tony Gaddis

Available Study Resources on Quizplus

20 Chapters

891 Verified Questions

891 Flashcards

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

Chapter 1: Introduction to Computers and Programming

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Which of the following is not one of the five major components of a computer system?

A)Preprocessor

B)The CPU (central processing unit)

C)Main memory

D)Input/Output device

E)Secondary storage device

Answer: A

Q2) An example of a secondary storage device is:

A)The computer's main memory

B)The keyboard

C)The monitor

D)The disk drive

E)None of the above

Answer: D

Q3) Pseudocode is a form of program statement that will always evaluate to "false."

A)True

B)False

Answer: False

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

Page 3

Chapter 2: Introduction to C Plus Plus

Available Study Resources on Quizplus for this Chatper

60 Verified Questions

60 Flashcards

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

Sample Questions

Q1) In programming terms, a group of characters inside a set of quotation marks is called a(n):

A)String literal

B)Variable

C)Operation

D)Statement

E)None of the above

Answer: A

Q2) This control sequence is used to skip over to the next horizontal tab stop.

A)\n

B)\h

C)\t

D)\a

E)\'

Answer: C

Q3) A preprocessor directive does not require a semicolon at the end.

A)True

B)False

Answer: True

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

Page 4

Chapter 3: Expressions and Interactivity

Available Study Resources on Quizplus for this Chatper

44 Verified Questions

44 Flashcards

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

Sample Questions

Q1) This manipulator causes the field to be left-justified with padding spaces printed to the right.

A)left_justify

B)right

C)left

D)left_pad

E)None of these

Answer: C

Q2) The function, pow(x, 5.0), requires this header file.

A)cstdlib

B)cmath

C)cstring

D)iostream

E)iomanip

Answer: B

Q3) The fixed manipulator causes a number to be displayed in scientific notation.

A)True

B)False

Answer: False

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

Page 5

Chapter 4: Making Decisions

Available Study Resources on Quizplus for this Chatper

53 Verified Questions

53 Flashcards

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

Sample Questions

Q1) These operators connect two or more relational expressions into one, or reverse the logic of an expression.

A)relational

B)logical

C)irrational

D)negation

E)None of these

Q2) If you intend to place a block of statements within an if statement, you must place these around the block.

A)Parentheses ( )

B)Square brackets [ ]

C)Angle brackets < >

D)Curly braces { }

E)None of these

Q3) Both of the following if statements perform the same operation. if (sales > 10000)

commissionRate = 0.15; if (sales > 10000)commissionRate = 0.15;

A)True

B)False

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

Chapter 5: Loops and Files

Available Study Resources on Quizplus for this Chatper

63 Verified Questions

63 Flashcards

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

Sample Questions

Q1) To read data from a file, you define an object of this data type.

A)inputFile

B)ifstream

C)fstream

D)ofstream

Q2) A for statement contains three expressions: initialization, test, and

A)update

B)reversal

C)null

D)validation

E)None of these

Q3) A loop that is inside another loop is called:

A)an infinite loop

B)a pre-test loop

C)a post-test loop

D)a nested loop

E)None of these

Q4) An output file is a file that data is written to.

A)True

B)False

Page 7

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

Chapter 6: Functions

Available Study Resources on Quizplus for this Chatper

49 Verified Questions

49 Flashcards

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

Sample Questions

Q1) This statement causes a function to end.

A)end

B)terminate

C)return

D)release

E)None of these

Q2) A parameter is a special-purpose variable that is declared inside the parentheses of a function definition.

A)True

B)False

Q3) One reason for using functions is to break programs into manageable units, or modules.

A)True

B)False

Q4) A ________ variable is declared outside all functions.

A)local

B)global

C)floating-point

D)counter

E)None of these

Page 8

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

Chapter 7: Arrays

Available Study Resources on Quizplus for this Chatper

58 Verified Questions

58 Flashcards

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

Sample Questions

Q1) If an array is partially initialized, the uninitialized elements will be set to zero.

A)True

B)False

Q2) In C++ 11, you cannot use a range-based for loop to modify the contents of an array unless you declare the range variable as a reference.

A)True

B)False

Q3) An individual array element can be processed like any other type of C++ variable.

A)True

B)False

Q4) It is ________ to pass an argument to a function that contains an individual array element, such as numbers[3].

A)illegal in C++

B)legal in C++

C)not recommended by the ANSI committee

D)not good programming practice

E)None of these

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

9

Chapter 8: Searching and Sorting Arrays

Available Study Resources on Quizplus for this Chatper

20 Verified Questions

20 Flashcards

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

Sample Questions

Q1) A binary search begins with the ________ element of an array.

A)first

B)last

C)largest

D)middle

E)None of these

Q2) The number of comparisons made by a binary search is expressed in powers of two.

A)True

B)False

Q3) In the average case, an item is just as likely to be found near the beginning of an array as near the end.

A)True

B)False

Q4) A(n)________ search is more efficient than a ________ search.

A)character, string

B)integer, double

C)binary, linear

D)linear, binary

E)None of these

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

Chapter 9: Pointers

Available Study Resources on Quizplus for this Chatper

45 Verified Questions

45 Flashcards

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

Sample Questions

Q1) When you pass a pointer as an argument to a function, you must ________.

A)declare the pointer variable again in the function call

B)dereference the pointer variable in the function prototype

C)use the #include&lt;func_ptr.h&gt; statement

D)not dereference the pointer in the function's body

E)None of these

Q2) If you are using an older compiler that does not support the C++ 11 standard, you should initialize pointers with ________.

A)the integer 0, or the value NULL

B)the null terminator '\0'

C)a nonzero value

D)All of these

E)None of these

Q3) The ________ and ________ operators can be used to increment or decrement a pointer variable.

A)addition, subtraction

B)modulus, division

C)++, --

D)All of these

E)None of these

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

Chapter 10: Characters, C-Strings, and More About the String Class

Available Study Resources on Quizplus for this Chatper

45 Verified Questions

45 Flashcards

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

Sample Questions

Q1) In C++, a C-string is a sequence of characters stored in consecutive memory, terminated by a ________.

A)period

B)space

C)null character

D)semicolon

E)None of these

Q2) By being able to pass arrays as arguments, you can write your own functions for processing C-strings.

A)True

B)False

Q3) The isdigit function will return a true if its argument is a digit between 0 and 9.

A)True

B)False

Q4) When using the strcat function, you must be careful not to overwrite the bounds of an array.

A)True

B)False

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

Chapter 11: Structured Data

Available Study Resources on Quizplus for this Chatper

53 Verified Questions

53 Flashcards

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

Sample Questions

Q1) You cannot directly assign an enumerator to an int variable.

A)True

B)False

Q2) A declaration for an enumerated type begins with the ________ key word.

A)enumerated

B)enum_type

C)enum

D)ENUM

Q3) Which of the following is an example of a C++ primitive data type?

A)unsigned short int

B)long double

C)unsigned char

D)All of these

E)None of these

Q4) The structure pointer operator is used to dereference a pointer to a structure, not a pointer that is a member of a structure.

A)True

B)False

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

Page 13

Chapter 12: Advanced File Operations

Available Study Resources on Quizplus for this Chatper

38 Verified Questions

38 Flashcards

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

Sample Questions

Q1) Outside of a C++ program, a file is identified by its ________. Inside a C++ program, a file is identified by a(n)________.

A)file number, file name

B)file name, file number

C)name, address

D)name, file stream object

E)None of these

Q2) When a file is opened, the file stream object's "read position" is ________.

A)at the end of the file

B)at the beginning of the file

C)nonexistent, until the programmer declares it

D)in the middle of the file

E)None of these

Q3) Which of the following statements opens the file info.txt for both input and output?

A)dataFile.open("info.txt", ios::in && ios::out);

B)dataFile.open("info.txt", ios::in , ios::out);

C)dataFile.open("info.txt", input || output);

D)dataFile.open("info.txt", ios::in | ios::out);

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

Page 14

Chapter 13: Introduction to Classes

Available Study Resources on Quizplus for this Chatper

47 Verified Questions

47 Flashcards

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

Sample Questions

Q1) This is used to protect important data.

A)public access specifier

B)private access specifier

C)protect()member function

D)class protection operator, @

E)None of these

Q2) This type of member function may be called from a statement outside the class.

A)public

B)private

C)undeclared

D)global

E)None of these

Q3) This is automatically called when an object is destroyed.

A)constructor function

B)specification deallocator

C)destructor function

D)coroner function

E)None of these

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

15

Chapter 14: More About Classes

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) If you do not furnish one of these, an automatic memberwise copy will be performed when one object is assigned to another object.

A)overloaded constructor function

B)overloaded assignment operator

C)default constructor function

D)overloaded copy operator

E)None of these

Q2) When you overload an operator, you can change the operator's original meaning to something entirely different.

A)True

B)False

Q3) C++ allows you to redefine the way ________ work when used with class objects.

A)compiler errors

B)preprocessor directives

C)standard operators

D)undefined variables

E)None of these

Q4) A non-static member function may not access a static member variable.

A)True

B)False

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

Chapter 15: Inheritance, Polymorphism, and Virtual Functions

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Protected members of a base class are like ________, but they may be accessed by derived classes.

A)constructor functions

B)static members

C)private members

D)public members

E)None of these

Q2) A derived class may not have any classes derived from it.

A)True

B)False

Q3) In C++ 11, if a derived class attempts to override a final member function, the compiler generates an error.

A)True

B)False

Q4) A derived class may become a base class, if another class is derived from it.

A)True

B)False

Q5) More than one class may be derived from a base class. A)True

B)False

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

Chapter 16: Exceptions, Templates, and the Standard

Template Library Stl

Available Study Resources on Quizplus for this Chatper

39 Verified Questions

39 Flashcards

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

Sample Questions

Q1) When an error occurs, an exception is ________.

A)created

B)thrown

C)passed

D)ignored

E)None of these

Q2) Types of iterators are ________.

A)input and output

B)forward and bidirectional

C)random-access

D)All of these

E)None of these

Q3) Function templates allow you to write a single function definition that works with many different data types.

A)True

B)False

Q4) Using a function template requires less code than overloading a function.

A)True

B)False

18

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

Chapter 17: Linked Lists

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) If new data needs to be added to a linked list, the program simply ________ and inserts it into the series.

A)allocates another node

B)removes a node

C)borrows a node from the compiler

D)Either B or C

E)None of these

Q2) When working with a linked list, one of the basic operations you can perform is to destroy the list.

A)True

B)False

Q3) How many steps are involved in the process of deleting a node?

A)one-delete the node from memory

B)two-remove the node without breaking links, then delete it from memory

C)three-create a blank node, remove the node being deleted, insert the blank, then delete the node

D)four-create a blank, remove the node being deleted, insert the blank, delete the node, delete the blank

E)None of these

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

Page 19

Chapter 18: Stacks and Queues

Available Study Resources on Quizplus for this Chatper

47 Verified Questions

47 Flashcards

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

Sample Questions

Q1) The queue data structure is commonly applied in connection with:

A)managing the order of print jobs

B)communications software

C)operating systems

D)All of these

E)None of these

Q2) The pop function in the stack template does not retrieve the value from the top of the stack. It merely removes it.

A)True

B)False

Q3) Data structures that can dynamically store elements and can grow and shrink in size are:

A)stacks

B)queues

C)deques

D)All of these

E)None of these

Q4) Endeque and deque are the two most common queue operations.

A)True

B)False

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

Chapter 19: Recursion

Available Study Resources on Quizplus for this Chatper

22 Verified Questions

22 Flashcards

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

Sample Questions

Q1) The recursive factorial function calculates the factorial of its parameter. Its base case is when the parameter is ________.

A)returned

B)received

C)amortized

D)zero

E)None of these

Q2) The speed and amount of memory available to modern computers diminishes the performance impact of recursion so much that inefficiency is no longer a strong argument against it.

A)True

B)False

Q3) Any algorithm that can be coded with recursion can also be coded with an iterative structure.

A)True

B)False

Q4) A recursive function cannot call another function.

A)True

B)False

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

Chapter 20: Binary Trees

Available Study Resources on Quizplus for this Chatper

38 Verified Questions

38 Flashcards

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

Sample Questions

Q1) Deleting a node that has two children offers an opportunity to use:

A)a function that returns a pointer to a pointer

B)a function parameter that is a pointer to a pointer

C)double indirection

D)All of these

E)None of these

Q2) When working with a binary tree, a node that has more than two children:

A)will be cut back by the compiler

B)is theoretically impossible in a correctly-developed binary tree structure

C)is known as a triplet node

D)None of these

Q3) The ________ in a binary tree is similar to the head pointer in a linked list.

A)root pointer

B)leaf pointer

C)null pointer

D)binary pointer

E)None of these

Q4) In a binary tree, each node must have a minimum of two children.

A)True

B)False

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

Turn static files into dynamic content formats.

Create a flipbook