Object-Oriented Programming Test Questions - 766 Verified Questions

Page 1


Object-Oriented Programming Test Questions

Course Introduction

Object-Oriented Programming is a foundational course that introduces students to the principles and concepts of designing software using the object-oriented paradigm.

Emphasizing encapsulation, inheritance, polymorphism, and abstraction, the course explores how complex problems can be modeled as interacting objects. Students learn to construct modular, reusable, and maintainable code through practical exercises and projects using languages such as Java or C++. The course also covers best practices, design patterns, and debugging techniques, preparing students for advanced software development and real-world application programming.

Recommended Textbook

Starting out with C++ Early Objects 9th Edition by Tony Gaddis

Available Study Resources on Quizplus

19 Chapters

766 Verified Questions

766 Flashcards

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

Chapter 1: Introduction to Computers and Programming

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Three primary activities of a typical program are

A) creating variables, operators, and keywords.

B) executing lines, statements, and keywords.

C) reading, writing, and arithmetic.

D) input, processing, and output.

E) compiling, linking, and debugging.

Answer: D

Q2) Syntax involves rules that must be followed when writing a program.

A)True

B)False

Answer: True

Q3) ________ is used in a C++ program to mark the end of a statement, or to separate items in a list.

A) A separator

B) Punctuation

C) An operator

D) A keyword

E) A blank space

Answer: B

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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) A variable of the char data type can hold a set of characters like "January".

A)True

B)False Answer: False

Q2) Which of the following keywords is/are the names of C++ data types?

A) short

B) long

C) double

D) bool

E) All of the above Answer: E

Q3) The following is a legal C++ statement to define and initialize a variable.

char firstName = "Jack";

A)True

B)False Answer: False

Q4) C++ is a case-sensitive language.

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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) When converting some algebraic expressions to C++, you may need to insert ________ and ________ that do not appear in the algebraic expression.

A) values, exponents

B) operators, calculations

C) operators, operands

D) operators, parentheses

E) operands, parentheses

Answer: D

Q2) Hand tracing a program is

A) a program design technique.

B) a program run-time testing technique.

C) a program debugging technique.

D) creating a drawing of what a program's output screen will look like.

E) none of the above.

Answer: C

Q3) The following C++ statement will assign 1.5 to the result variable. int result = 3.0 / 2.0;

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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Relational operators allow you to ________ numbers.

A) add

B) multiply

C) compare

D) average

E) verify

Q2) What will the following expression evaluate to?

!( 6 > 7 || 3 == 4)

A) 0

B) -1

C) 6

D) True

E) false

Q3) The ________ operator is known as the logical OR operator.

A) !

B) &

C) &&

D) ||

E) //

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

Page 6

Chapter 5: Looping

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) For data validation, it is best to use a(n)

A) if statement.

B) while loop.

C) for loop.

D) nested loop.

E) switch statement.

Q2) The statements in the body of a do-while loop are executed

A) exactly once.

B) at least once.

C) only if the test condition is initially True.

D) until the test condition becomes True.

E) forever until the user hits the break key.

Q3) In order for a C++ program to read data from a file,

A) the file must already exist.

B) the program must define a file stream object that can "point to" (i.e., reference) the file.

C) the program must open the file.

D) All of the above are required.

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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Functions are ideal for use in menu-drive programs. When a user selects a menu item, the program can call an appropriate function to carry out the user's choice.

A)True

B)False

Q2) When a function just needs to use a copy of an argument passed to it, the argument should normally be passed by value.

A)True

B)False

Q3) A function ________ is a statement that causes a function to execute.

A) prototype

B) header

C) definition

D) call

E) parameter list

Q4) If a function has no return statement, the flow of control moves to the next function in the file when the closing brace of the function body is reached.

A)True

B)False

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

Chapter 7: Introduction to Classes and Objects

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Which of the following statements correctly creates an enumerated data type and defines an object of that type.

A) enum Season = {"Spring", "Summer", "Fall", "Winter"} favoriteSeason;

B) enum Season = {Spring, Summer, Fall, Winter}, Season favoriteSeason;

C) enum Season {Spring, Summer, Fall, Winter}, enum favoriteSeason;

D) ENUM Season {Spring, Summer, Fall, Winter} favoriteSeason;

E) None of these

Q2) In C++ and other object-oriented programming languages, ADTs are normally implemented as classes.

A)True

B)False

Q3) A class declaration provides a pattern for creating objects, but doesn't make any objects.

A)True

B)False

Q4) A private member function may only be called from a function that is a member of the same class.

A)True

B)False

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

Chapter 8: Arrays

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Subscript numbering in C++

A) can be set at run time.

B) can begin with a programmer-defined value.

C) varies from program to program.

D) automatically begins with zero.

E) automatically begins with one.

Q2) Which of the following statements will correctly carry out the operation stated in the comment to its right.

A) array 2 = array1 // Copy the elements of array 1 into array 2.

B) cout << array2 // Output the elements stored in array 2.

C) array2 = 5; // Place a 5 in each element of array2.

D) None of the above.

E) A and B, but not C.

Q3) Arrays can be passed to functions, but individual array elements cannot be.

A)True

B)False

Q4) An individual array element can be processed or passed to a function just like a regular C++ variable.

A)True

B)False

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

Chapter 9: Searching, Sorting, Algorithm Analysis

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) If algorithm A requires 2n + 1 basic operations to process an input of size n, and Algorithm B requires 3n + 2 basic operations to process the same input, algorithms A and B are considered to be equally efficient.

A)True

B)False

Q2) Using a binary search, you are more likely to find an item than if you use a linear search.

A)True B)False

Q3) A sorting algorithm can be used to arrange a set of ________ in ________ order. A) numeric values, ascending B) numeric values, descending C) strings, ascending D) strings, descending E) All of the above.

Q4) Using a linear search, you are more likely to find an item than if you use a binary search.

A)True B)False

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

Chapter 10: Pointers

Available Study Resources on Quizplus for this Chatper

62 Verified Questions

62 Flashcards

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

Sample Questions

Q1) If dynamically allocated memory is not freed,

A) the system may run out of memory.

B) it results in a compiler error.

C) a run-time error informs your user that the program did not free memory space.

D) the source code will not link correctly.

E) None of the above

Q2) The term pointer can be used interchangeably with A) address.

B) variable.

C) decimal pointer.

D) counter pointer.

E) None of the above

Q3) The statement double *num;

A) defines a variable of type double called num.

B) defines and initializes a pointer variable called num.

C) initializes a variable called *num.

D) defines a pointer variable called num.

E) None of the above

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

Chapter 11: More About Classes and Object-Oriented Programming

Available Study Resources on Quizplus for this Chatper

70 Verified Questions

70 Flashcards

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

Sample Questions

Q1) The this pointer is a special built-in pointer that is automatically passed as a hidden argument to all instance member functions.

A)True

B)False

Q2) ________ is commonly used to extend a class, or to give it additional capabilities.

A) Inheritance

B) Privacy

C) The constructor

D) The destructor

E) None of the above

Q3) It is a good idea to make a copy constructor's parameters ________ by specifying the ________ keyword in the parameter list.

A) inline, inline

B) static, static

C) constant, const

D) global, glob

E) None of the above

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

Page 13

Chapter 12: More on C-Strings and the String Class

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The expression str1 < str 2 is True when

A) the string object str1 precedes the string str 2 in alphabetic order.

B) the string str1 converted to numeric form is less than the string str2 converted to numeric form.

C) the length of the string str1 is less than the length of the string str2.

D) the C-string "str1" precedes the C-string "str2" in alphabetic order.

E) None of the above

Q2) There exist C++ stream classes that write and read in-memory strings.

A)True

B)False

Q3) To access the last character of a string class object str you can use the expression A) str[last].

B) str.last().

C) str[str.length()].

D) str[str.length()-1].

E) None of the above

Q4) A C-string can be assigned to a variable whose type is the string class.

A)True

B)False

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

Chapter 13: Advanced File and Io Operations

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The process of writing in-memory objects to a file so that the object can later be read back into memory

A) requires the use of specialized convert constructors.

B) is called serialization.

C) requires special operation system support.

D) is called deserialization.

E) None of the above

Q2) Which statement opens a file and links it to a file stream object?

A) open(AFile) = link(anObject);

B) file.open("filename.txt");

C) linkstream("filename.txt");

D) link(open(filename.txt"));

E) None of the above

Q3) Opening a file with the flags ios::in | ios::out will preserve the contents of the file if the file already exists.

A)True

B)False

Q4) The ios::hardfail bit is set when an unrecoverable error occurs.

A)True

B)False

Page 15

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

Chapter 14: Recursion

Available Study Resources on Quizplus for this Chatper

20 Verified Questions

20 Flashcards

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

Sample Questions

Q1) Indirect recursion means that a function calls itself several times.

A)True

B)False

Q2) A ________ function is one that calls itself.

A) dynamic

B) static

C) recursive

D) data validation

E) None of the above

Q3) The quicksort algorithm works on the basis of

A) three sublists.

B) two sublists and a pivot.

C) two pivots and a sublist.

D) three pivots.

E) None of the above

Q4) A recursive function cannot call a function other than itself.

A)True

B)False

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

Page 16

Chapter 15: Polymorphism and Virtual Functions

Available Study Resources on Quizplus for this Chatper

22 Verified Questions

22 Flashcards

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

Sample Questions

Q1) In C++ polymorphism is very difficult to achieve unless you also use inheritance.

A)True

B)False

Q2) When more than one class is derived from a base class, the situation is called

A) polymorphism.

B) population.

C) multiplicity.

D) encapsulation.

E) None of the above

Q3) An abstract class is somewhat restricted in how it can be used because

A) it cannot use dynamic binding for its member functions.

B) it cannot use static binding for its member functions.

C) All of its members must be public.

D) the compiler does not allow objects of the class to be created.

E) None of the above

Q4) Pointers to a base class may be assigned the address of a derived class object.

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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The STL vector and list classes are examples of sequential containers.

A)True

B)False

Q2) Iterators are objects that are similar to pointers.

A)True

B)False

Q3) The Standard Template Library (STL) contains templates for useful algorithms and data structures.

A)True

B)False

Q4) A catch block serves as

A) an exception handler.

B) an indicator of program correctness.

C) a temporary variable.

D) permanent storage for trapped errors.

E) None of the above

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

A)True

B)False

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

Chapter 17: Linked Lists

Available Study Resources on Quizplus for this Chatper

38 Verified Questions

38 Flashcards

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

Sample Questions

Q1) If a node is not the first node in a linked list, deleting it may require setting the successor pointer in its predecessor.

A)True

B)False

Q2) To concatenate two linked lists, it is necessary to

A) traverse one of the lists to get to its end.

B) traverse both lists to get to their ends.

C) first reverse one of the lists.

D) first reverse both lists.

E) None of the above

Q3) The values stored in the value portion of a node of a linked list can be simple data types, structures, objects of classes, or any other data type.

A)True

B)False

Q4) When you create a linked list, you must know in advance how many nodes the list will contain.

A)True

B)False

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

36 Verified Questions

36 Flashcards

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

Sample Questions

Q1) The pop function in the stack template of the STL does not return the value from the top of the stack.

A)True

B)False

Q2) The Standard Template Library offers a stack template that may be implemented as a

A) vector.

B) deque.

C) linked list.

D) All of the above

E) None of the above

Q3) The ________ operation allows an item to be stored on a stack.

A) append

B) add

C) pop

D) push

E) None of the above

Q4) The programmer must declare in advance the size of a dynamic stack or queue. A)True

B)False

Page 20

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

Chapter 19: Binary Trees

Available Study Resources on Quizplus for this Chatper

38 Verified Questions

38 Flashcards

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

Sample Questions

Q1) Values are commonly stored in a binary search tree so that a node's ________ child holds data that is less than the ________ data, while the node's data is less than the data in the other child.

A) right, node's

B) left, node's

C) right, left child's

D) left, right child's

E) None of the above

Q2) Binary search trees may be implemented as templates, but any data types used with them should support the ________ operator.

A) <

B) >

C) ==

D) All of the above

E) None of the above

Q3) In a binary search tree where all the stored values are different, the node holding the largest value cannot have two children.

A)True

B)False

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

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.