Object-Oriented Programming Final Test Solutions - 899 Verified Questions

Page 1


Object-Oriented Programming Final

Test Solutions

Course Introduction

Object-Oriented Programming is a foundational course that introduces students to the principles and practices of designing software using the object-oriented paradigm. The course covers key concepts such as classes, objects, inheritance, encapsulation, polymorphism, and abstraction. Through hands-on programming assignments and projects, students learn how to model real-world problems, construct modular and reusable code, and apply object-oriented techniques to develop maintainable applications. By the end of the course, students gain proficiency in writing well-structured software using an object-oriented programming language, preparing them for more advanced computer science topics and professional programming environments.

Recommended Textbook

C++ Programming From Problem Analysis to Program Design 6th Edition by

Available Study Resources on Quizplus

18 Chapters

899 Verified Questions

899 Flashcards

Source URL: https://quizplus.com/study-set/1103

Page 2

D.S. Malik

Chapter 1: An Overview of Computers and Programming Languages

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) C++ programs have always been portable from one compiler to another.

A)True

B)False

Answer: False

Q2) In ____________________ design, the final program is a collection of interacting objects.

Answer: object-oriented object oriented

Q3) The devices that the computer uses to display results are called ____ devices.

A) exit

B) entry

C) output

D) input

Answer: C

Q4) The ASCII data set consists of ____________________ characters. Answer: 128

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

Chapter 2: Basic Elements of C

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) A(n) ____________________ is a memory location whose contents can be changed.

Answer: variable

Q2) The escape sequence \r moves the insertion point to the beginning of the next line.

A)True

B)False

Answer: False

Q3) A mixed arithmetic expression contains all operands of the same type.

A)True

B)False

Answer: False

Q4) ____ is a valid int value.

A) 46,259

B) 46259

C) 462.59

D) -32.00

Answer: B

Q5) The smallest individual unit of a program written in any language is called a(n) ____________________.

Answer: token

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

Chapter 3: Inputoutput

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The function ____________________ returns the next character in the input stream; it does not remove the character from the input stream.

Answer: peek

Q2) To use the manipulator setprecision, the program must include the header file ____________________.

Answer: iomanip

Q3) Suppose that x and y are int variables, z is a double variable, and the input is:

12

Choose the values of x, y, and z after the following statement executes: Cin >> x >> y >> z;

A) x = 28, y = 32, z = 0.6

B) x = 28, y = 32, z = 12.0

C) x = 28, y = 12, z = 32.6

D) x = 28, y = 12, z = 0.6

Answer: A

Q4) In C++, the dot is an operator called the ____________________operator.

Answer: member access

Q5) cin is called a(n) ____________________ object.

Answer: istream

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

Chapter 4: Control Structures I Selection

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The term ____________________ describes a process in which the computer evaluates a logical expression from left to right and stops as soon as the value of the expression is known.

Q2) The expression (x >= 0 && x <= 100) evaluates to false if either x < 0 or x >= 100. A)True B)False

Q3) What is the output of the following C++ code? int x = 35; int y = 45; int z; if (x > y)

\(\quad\)z = x + y; else

\(\quad\)z = y - x; cout << x << " " << y << " " << z << endl;

A) 35 45 80

B) 35 45 10

C) 35 45 -10

D) 35 45 0

Q4) The value of the expression 7 + 8 <= 15 is ____________________.

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

Chapter 5: Control Structures II Repetition

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Suppose sum, num, and j are int variables, and the input is 4 7 12 9 -1. What is the output of the following code? cin >> sum; cin >> num; for (j = 1; j <= 3; j++) { \(\quad\)cin >> num; \(\quad\)sum = sum + num; }

cout << sum << endl;

A) 24

B) 25

C) 41

D) 42

Q2) A semicolon at the end of the for statement (just before the body of the loop) is a(n) ____________________ error.

Q3) In a(n) "____________________" problem, either the loop executes one too many or one too few times.

Q4) A software ____________________ is a piece of code written on top of an existing piece of code intended to fix a bug in the original code.

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

Chapter 6: User-Defined Functions

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) In C++, :: is called the ____________________.

Q2) Assume the following. static_cast&lt;int&gt;('a') = 97 Static_cast&lt;int&gt;('A') = 65

The output of the statement: Cout << static_cast&lt;int&gt;(tolower('B')) << endl; is ____.

A) 65

B) 67

C) 96

D) 98

Q3) The following function heading in a C++ program is valid: int funcExp(int u, char v, float g)

A)True

B)False

Q4) The ____________________ of an identifier refers to where in the program an identifier is accessible (visible).

Q5) Stream variables (for example, ifstream and ofstream) should be passed by ____________________ to a function.

Q6) A function ____________________ is a function that is not fully coded.

Q7) The program that tests a function is called a(n) ____________________ program.

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

Chapter 7: User-Defined

Simple Data Types, Namespaces, and the String Type

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) In July ____, ANSI/ISO Standard C++ was officially approved.

A) 1996

B) 1998

C) 1999

D) 2000

Q2) Suppose that str1, str2, and str3 are string variables. After the following statements execute, the value of str3 is "____". str1 = "abc";

Str2 = "xyz";

Str3 = str1 + '-' + str2;

A) abc

B) xyz

C) abc-xyz

D) xyz-abc

Q3) The string expression strVar.____________________ deletes n characters from strVar starting at position pos.

Q4) An enumeration type can be passed as a parameter to a function only by value.

A)True

B)False

9

Q5) The values in the domain of an enumeration type are called

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

Chapter 8: Arrays and Strings

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) What is the output of the following C++ code? int list[5] = {0, 5, 10, 15, 20}; int j; for (j = 0; j < 5; j++)

\(\quad\)cout << list[j] << " "; cout << endl;

A) 0 1 2 3 4

B) 0 5 10 15

C) 0 5 10 15 20

D) 5 10 15 20

Q2) The following statement creates alpha to be a two-dimensional array with ____________________ rows. int alpha[10][25];

Q3) In a two-dimensional array, the elements are arranged in a table form. A)True B)False

Q4) In a(n) ____________________ data type, each data item is a collection of other data items.

Q5) For a list of length n, the ____________________ sort makes exactly (n(n - 1))/2 key comparisons and 3(n-1) item assignments.

Page 10

Q6) The statement strlen("Marylin Stewart"); returns ____________________.

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

Chapter 9: Records Structs

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) A struct is a(n) ____________________, not a declaration.

Q2) To compare struct variables, you compare them ____.

A) by reference

B) by value

C) index-wise

D) member-wise

Q3) Consider the following struct definition: struct rectangleData

{

\(\quad\)double length;

\(\quad\)double width;

\(\quad\)double area;

\(\quad\)double perimeter;

};

Which of the following variable declarations is correct?

A) rectangle rectangleData; B) struct rectangleData();

C) rectangleData myRectangle;

D) rectangleData rectangle = new rectangleData();

Q4) Both arrays and structs are examples of ____________________ data types.

Q5) A(n) ____________________ is a set of elements of the same type.

Page 11

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

Chapter 10: Classes and Data Abstraction

Available Study Resources on Quizplus for this Chatper

49 Verified Questions

49 Flashcards

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

Sample Questions

Q1) In C++, the ____ is an operator called the member access operator.

A) .

B) ,

C) ::

D) #

Q2) To guarantee that the member variables of a class are initialized, you use ____.

A) accessors

B) mutators

C) constructors

D) destructor

Q3) In C++, the scope resolution operator is ____.

A) :

B) ::

C) $

D) .

Q4) As parameters to a function, class objects can be passed by reference only.

A)True

B)False

Q5) A C++ implementation file has the extension ____________________.

Q6) Object code is produced from a(n) ____________________.

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

Chapter 11: Inheritance and Composition

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Classes can create new classes from existing classes. This important feature ____.

A) encourages code reuse

B) aids the separation of data and operations

C) provides public access to the internal state of an object

D) results in more software complexity

Q2) A derived class cannot directly access public members of a base class.

A)True

B)False

Q3) If inheritance is public, all protected members of the base class are ____________________ members of the derived class.

Q4) To define new classes in C++, you create new ____________________ files.

Q5) To ____ a public member function of a base class in the derived class, the corresponding function in the derived class must have the same name, number, and types of parameters.

A) redefine

B) overload

C) rename

D) reuse

Q6) Objects are created when ____________________ variables are declared.

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

Chapter 12: Pointers, Classes, Virtual Functions, and

Abstract Classes

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The copy constructor automatically executes when, as a parameter, an object is passed by ____________________.

Q2) The statement that declares board to be a pointer to a pointer is: int ____________________;

Q3) The C++ operator ____ is used to create dynamic variables.

A) dynamic

B) new

C) virtual

D) dereferencing

Q4) Which of the following would be appropriate syntax for the heading of a copy constructor for a class called rulerType?

A) rulerType(int inches, int centimeters)

B) rulerType()

C) rulerType(const rulerType& myRuler)

D) copy rulerType(int inches, int centimeters)

Q5) A memory leak is an unused memory space that cannot be allocated.

A)True

B)False

14

Q6) The binding of virtual functions occurs at program ____________________ time.

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

Page 15

Chapter 13: Overloading and Templates

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) A class template is called a(n) ____________________ type because it specifies how a generic class template is to be customized to form a specific template class.

Q2) When an object invokes a member function, the member function references the pointer ____ of the object.

A) object

B) it

C) this

D) address

Q3) Both parameters of the function to overload the operator << are reference parameters.

A)True

B)False

Q4) The general form of the functions to overload the binary operators as member functions of a class is returnType operator#(____ className&) const;.

A) class

B) const

C) *

D) &

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

Chapter 14: Exception Handling

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The logic_error and runtime_error classes are defined in the header file ____.

A) stdex

B) stdlib

C) stdexcept

D) exception

Q2) A(n) ____ is an occurrence of an undesirable situation that can be detected during program execution.

A) crash

B) exception

C) misfire

D) bug

Q3) When division by zero occurs and the problem is not addressed, the program crashes with an error message that is ____ dependent.

A) code

B) computer

C) platform

D) IDE

Q4) An object that is being thrown cannot be an anonymous object.

A)True

B)False

Page 17

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

Chapter 15: Recursion

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) A recursive function in which the last statement executed is the recursive call is called a(n) ____ recursive function.

A) direct

B) tail

C) indefinite

D) indirect

Q2) The language of a computer, called ____________________ language, is a series of 0s and 1s.

Q3) Consider the accompanying definition of a recursive function. What is the output of the following statement? cout << recFunc(10) << endl;

A) 10

B) 11

C) 100

D) 110

Q4) With recursion, the base case must eventually be reduced to a general case.

A)True

B)False

Q5) The collating sequence of A in the ASCII character set is

Page 18

Q6) The rightmost bit of the binary representation of 33 is ____________________.

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

Chapter 16: Searching, Sorting and the Vector Type

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The statement ____ returns the element at the position index in vector vecList.

A) vecList[index]

B) vecList.get(index)

C) vecList.front(index)

D) vecList&lt;index&gt;

Q2) The type vector provides the expression ____________________, which deletes the last element of vecList.

Q3) A sequential search is much faster than a binary search.

A)True

B)False

Q4) The type vector provides the expression ____________________, which returns the last element of the object.

Q5) All of the values in a list have the same type.

A)True

B)False

Q6) The type vector provides the function ____________________, which deletes all elements from the object.

Q7) The type vector provides the expression ____________________, which inserts a copy of elem into vecList at the end.

Page 19

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

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) In a linked list, the link component of each node is a(n) ____________________.

Q2) A(n) ____________________ linked list is a linked list in which every node has a next pointer and a back pointer.

Q3) Which of the following correctly initializes a doubly linked list in the default constructor?

A) head = NULL;

Back = NULL;

B) head = 0;

Back = 0;

Count = 0;

C) first = 0; Last = 0;

D) first = NULL; Last = NULL; Count = 0;

Q4) We deallocate the memory for a linked list by calling the operator clear. A)True B)False

Q5) The nodes of an ordered list are in ____________________ order.

Q6) In C++, the dereferencing operator is ____________________.

Page 20

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

Chapter 18: Stacks and Queues

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The postfix expression 3 5 + 2 ; 6 - = will generate an error, because it ____.

A) contains an illegal operator

B) does not have enough operands

C) has too many operands

D) has too many operators

Q2) Postfix notation requires the use of parentheses to enforce operator precedence.

A)True

B)False

Q3) In a queuing system, every customer has a customer number, arrival time, ____________________ time, transaction time, and departure time.

Q4) A(n) ____ is a list of homogenous elements in which the addition and deletion of elements occurs only at one end.

A) stack

B) queue

C) array

D) linked list

Q5) The expression a + b is the same in both infix notation and postfix notation. 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.
Object-Oriented Programming Final Test Solutions - 899 Verified Questions by Quizplus - Issuu