Skip to main content

Intermediate Programming with C++ Exam Bank - 1050 Verified Questions

Page 1


Intermediate Programming with C++ Exam Bank

Course Introduction

Intermediate Programming with C++ builds upon fundamental programming concepts to deepen students' understanding of the C++ language and its application in software development. The course covers advanced topics such as object-oriented programming, inheritance, polymorphism, templates, exception handling, and the Standard Template Library (STL). Students will practice problem-solving and algorithm development while working on more complex coding projects, emphasizing code efficiency, reusability, and maintainability. By the end of the course, students will have the skills necessary to design and implement robust C++ applications and prepare for more advanced computer science courses.

Recommended Textbook C++ Programming Program Design Including Data Structures 6th Edition by D.S. Malik

Available Study Resources on Quizplus

21 Chapters

1050 Verified Questions

1050 Flashcards

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

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

Sample Questions

Q1) The device that stores information permanently (unless the device becomes unusable or you change the information by rewriting it)is called primary storage.

A)True

B)False

Answer: False

Q2) The machine language version of the high-level language program is called a(n)____________________.

Answer: object program

Q3) The basic commands that a computer performs are input (get data),output (display result),storage,and performance of arithmetic and logical operations.

A)True

B)False

Answer: True

Q4) Assembly language uses easy-to-remember instructions called ____________________.

Answer: mnemonics

Q5) A sequence of 0s and 1s is sometimes referred to as ____________________ code.

Answer: binary

Page 3

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

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

Sample Questions

Q1) The memory allocated for a float value is ____ bytes.

A) two

B) four

C) eight

D) sixteen

Answer: B

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

Answer: variable

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

Answer: token

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

A)True

B)False

Answer: False

Q5) When a value of one data type is automatically changed to another data type,a(n)____________________ type coercion is said to have occurred.

Answer: implicit

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

Chapter 3: Input/Output

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Suppose that x = 1565.683,y = 85.78,and z = 123.982.What is the output of the following statements?

cout << fixed << showpoint; Cout << setprecision(3)<< x << ' '; Cout << setprecision(4)<< y << ' ' << setprecision(2)<< z << endl;

A) 1565.683 85.8000 123.98

B) 1565.680 85.8000 123.98

C) 1565.683 85.7800 123.98

D) 1565.683 85.780 123.980

Answer: C

Q2) It is a good idea to redefine cin and cout in your programs. A)True

B)False Answer: False

Q3) When reading data into a char variable,after skipping any leading whitespace characters,the extraction operator >> finds and stores only the next character; reading stops after a single character.

A)True

B)False Answer: True

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

Sample Questions

Q1) Suppose that x is an int variable.Which of the following expressions always evaluates to true?

A) (x > 0) || ( x <= 0)

B) (x >= 0) || (x == 0)

C) (x > 0) && ( x <= 0)

D) (x > 0) && (x == 0)

Q2) Putting ____________________ in front of a logical expression reverses the value of that logical expression.

Q3) Which of the following is the "not equal to" relational operator?

A) !

B) |

C) !=

D) &

Q4) The expression in an if statement is sometimes called a(n)____.

A) selection statement

B) action statement

C) decision maker

D) action maker

Q5) A(n)____________________ structure does not require the evaluation of a logical expression.

6

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

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

Sample Questions

Q1) Which of the following is a repetition structure in C++?

A) if

B) switch

C) while...do

D) do...while

Q2) Assume that all variables are properly declared.The following for loop executes 20 times.

for (i = 0; i <= 20; i++) \(\quad\)cout << i;

A)True

B)False

Q3) A do...while loop is a(n)____________________ loop,since the loop condition is evaluated after executing the body of the loop.

Q4) Which of the following loops does not have an entry condition?

A) EOF-controlled while loop

B) sentinel-controlled while loop

C) do...while loop

D) for loop

Q5) A for loop is typically called a counted or ____________________ for loop.

Q6) The ____________________ loop has an exit condition but no entry condition.

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

Sample Questions

Q1) Which of the following function prototypes is valid?

A) int funcTest(int x, int y, float z){}

B) funcTest(int x, int y, float){};

C) int funcTest(int, int y, float z)

D) int funcTest(int, int, float);

Q2) A variable for which memory is allocated at block entry and deallocated at block exit is called a(n)____________________ variable.

Q3) A(n)____________________ parameter is a formal parameter that receives the location (memory address)of the corresponding actual parameter.

Q4) Assume that all variables are properly declared.The following statement in a value-returning function is legal. if (x % 2 == 0)

\(\quad\)return x; else

\(\quad\)return x + 1; A)True B)False

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

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

Page 8

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

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

Sample Questions

Q1) Which of the following statements declares the studentGrade variable?

A) enum studentGrade {A, B, C, D, F};

B) enum int {A, B, C, D, F} studentGrade;

C) enum studentGrade {A, B, C, D, F} grades;

D) enum grades {A, B, C, D, F} studentGrade;

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

Q3) Consider the following statements: string str = "ABCDEFD"; String::size_type position;

After the statement position = str.find('D'); executes,the value of position is ____.

A) 3

B) 4

C) 6

D) 7

Q4) Which of the following statements is used to simplify the accessing of all globalType namespace members?

A) using globalType;

B) using namespace globalType:all;

C) using namespace globalType::all; D) using namespace globalType;

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

Chapter 8: Arrays and Strings

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Suppose list is a one dimensional array of size 25,wherein each component is of type int.Further,suppose that sum is an int variable.The following for loop correctly finds the sum of the elements of list. sum = 0; for (int i = 0; i < 25; i++) sum = sum + list;

A)True

B)False

Q2) The array index can be any integer less than the array size. A)True

B)False

Q3) A collection of a fixed number of elements (called components)arranged in n dimensions (n>=1)is called a(n)____.

A) matrix

B) vector

C) n-dimensional array

D) parallel array

Q4) The function ____________________ returns the length of the string s,excluding the null character.

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

Chapter 9: Records (structs)

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Which of the following struct definitions is correct in C++?

A) struct studentType

{ \(\quad\)int ID;

B) struct studentType

{ \(\quad\)string name; \(\quad\)int ID; \(\quad\)double gpa;

C) int struct studentType

{ \(\quad\)ID;

D) struct studentType

{ \(\quad\)int ID = 1;

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

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

Page 11

Chapter 10: Classes and Data Abstraction

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) How many destructors can a class have?

A) no explicit destructors

B) one

C) two

D) any number

Q2) A class is an example of a structured data type.

A)True

B)False

Q3) A class object can be ____.That is,it can be created once,when the control reaches its declaration,and destroyed when the program terminates.

A) static

B) automatic

C) local

D) public

Q4) If an object is declared in the definition of a member function of the class,then the object can access both the public and private members of the class.

A)True

B)False

Q5) A constructor with no parameters is called the ____________________ constructor.

12

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

Chapter 11: Inheritance and Composition

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The ____ members of an object form its internal state.

A) private

B) protected

C) public

D) static

Q2) Which of the following statements about inheritance is true if memberAccessSpecifier is protected?

A) The private members of the base class become protected members of the derived class.

B) The derived class can directly access any member of the base class.

C) The public members of the base class become protected members of the derived class.

D) The protected members of the base class become private members of the derived class.

Q3) In C++,we implement ADT through the use of ____________________.

Q4) ____ is the ability to use the same expression to denote different operations.

A) Inheritance

B) Encapsulation

C) Polymorphism

D) Composition

Page 13

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

Chapter 12: Pointers, Classes, Virtual Functions, Abstract

Classes, and Lists

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) A list is a collection of elements of the same type.

A)True

B)False

Q2) Run-time binding is also known as ____ binding.

A) static

B) shallow

C) dynamic

D) deep

Q3) Given the declaration int *a;,the statement a = new int[50]; dynamically allocates an array of 50 components of the type ____.

A) int

B) int*

C) pointer

D) address

Q4) In C++,you declare a pointer variable by using the ____ symbol.

A) *

B) &

C) #

D) @

Page 14

Q5) 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/5316

Sample Questions

Q1) The operator function that overloads the insertion operator,<<,or the extraction operator,>>,for a class must be a(n)____________________ function of that class.

Q2) The ____________________ members of a class are local to the class and,therefore,cannot be accessed outside of the class.

Q3) Which of the following is the syntax to overload the operator function operator[] as a member function of a class for constant arrays?

A) const Type& []operator(int index) const;

B) const Type& operator[](int index) const;

C) const Type& operator[](int index);

D) const Type [](int index) const;

Q4) In C++,a function ____________________ can be overloaded.

Q5) In C++,>> is used as a stream extraction operator and as a right shift operator.

A)True

B)False

Q6) In C++,operator is a reserved word.

A)True

B)False

Q7) A conversion constructor is a(n)____________________ parameter function.

Page 16

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

Chapter 14: Exception Handling

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Which of the following classes is derived from the class runtime_error?

A) bad_alloc

B) out_of_range

C) overflow_error

D) length_error

Q2) Suppose you have written a program that inputs data from a file.If the input file does not exist when the program executes,then which option should you choose for handling the issue?

A) Terminate the program.

B) Include code in the program to recover from the exception.

C) Log the error and continue.

D) Include code in the header file.

Q3) Which of the following blocks is designed to catch any type of exception?

A) catch(){ }

B) catch(...){ }

C) catch(*){ }

D) catch(exception){ }

Q4) The class ____________________ deals with the string subscript out of range error.

Q5) The class ____________________ contains the function what.

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

Sample Questions

Q1) Suppose that function A calls function B,function B calls function C,function C calls function D,and function D calls function A.Function A is then ____________________ recursive.

Q2) Consider the following recursive definition,where n is a positive integer.

F(1)= 3

F(n)= F(n - 1)+ 1 if n > 1 The value of F(3)is ____________________.

Q3) ____ control structures use a looping structure,such as while,for,or do...while,to repeat a set of statements.

A) Iterative

B) Recursive

C) Procedural

D) Object

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

Q5) Which of the following solutions is easier to construct for the Tower of Hanoi problem?

A) Recursive

B) Iterative

C) Procedural

D) Step-by-step

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

Chapter 16: Linked Lists

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Consider the following code,which deletes all the nodes in a linked list. void doublyLinkedList&lt;Type&gt;::destroy()

{ \(\quad\)NodeType&lt;Type&gt; *temp; //pointer to delete the node \(\quad\)While (first != NULL) \(\quad\){

\(\quad\)\(\quad\)Temp = first; \(\quad\)\(\quad\)First = first-&gt;next; \(\quad\)\(\quad\)____ \(\quad\)}

\(\quad\)Last = NULL; \(\quad\)Count = 0;

}

Which of the following is the missing statement?

A) delete first; B) delete temp; C) destroy temp; D) clear temp;

Q2) In C++,the dereferencing operator is represented by the ____________________ symbol.

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

Chapter 17: Stacks and Queues

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) In the linked implementation of stacks,the stack is ____________________ only if you run out of memory space.

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

Q3) A queue is a data structure in which the elements are ____. A) added to the rear and deleted from the front B) added to and deleted from the rear C) added to and deleted from the front D) added and deleted in the middle

Q4) The expression (a - b)* (c + d)is equivalent to which of the following postfix expressions?

A) a b c d - + *

B) a b - c d + *

C) a b - + c d *

D) - + * a b c d

Q5) In a queuing system,we use a(n)____________________ variable to set the status of the server.

Q6) The elements at the ____________________ of a stack have been in the stack the longest.

Page 20

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

Chapter 18: Searching and Sorting Algorithms

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The binary search algorithm can be written iteratively or recursively.

A)True

B)False

Q2) The ____________________ search algorithm is the optimal worst-case algorithm for solving search problems by using the comparison method.

Q3) When moving array values for insertion sort,to move list[4] into list[2],first ____.

A) move list[2] to list[3]

B) delete list[2]

C) move list[4] to list[3]

D) copy list[4] into temp

Q4) The behavior of quick sort is ____ in the worst case and ____ in the average case.

A) O(nlog<sub>2</sub>n), O(nlog<sub>2</sub>n)

B) O(n<sup>2</sup>), O(n)

C) O(nlog<sup>2</sup>n), O(n<sup>2</sup>)

D) O(n<sup>2</sup>), O(nlog<sub>2</sub>n)

Q5) The quick sort algorithm uses the ____________________ technique to sort a list.

Q6) The top node of a comparison tree is call the ____________________ node.

Q7) A comparison tree is a(n)____________________ tree.

Page 21

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

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Let T be a binary search tree with n nodes,in which n > 0.When T is linear,the search algorithm makes ____________________ key comparisons,in the unsuccessful case.

Q2) The listing of the nodes produced by the inorder traversal of a binary tree is called the ____________________.

Q3) In a(n)____________________ traversal,the binary tree is traversed as follows:

1. Visit the node.

2.Traverse the left subtree.

3.Traverse the right subtree.

Q4) Assume the key of the left child below the root node of a binary search tree is 30.The value in the root node could be ____.

A) 0

B) 10

C) 30

D) 40

Q5) Let T be a binary search tree with n nodes,in which n > 0.The number of key comparisons is approximately O(____________________).

Q6) The ____________________ of a path in a binary tree is the number of branches on that path.

Page 22

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

Chapter 20: Graphs

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The shortest path algorithm was developed by ____.

A) Euler

B) Kruskal

C) Prim

D) Dijkstra

Q2) In a directed graph,the pairs (u,v)and (v,u)represent the same edge.

A)True

B)False

Q3) A minimal spanning tree of G is a spanning tree with the minimum ____.

A) path

B) cycle

C) weight

D) height

Q4) The depth first traversal is similar to the postorder traversal of a binary tree.

A)True

B)False

Q5) Linked lists cannot be used to implement an adjacency list.

A)True

B)False

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

Chapter 21: Standard Template Library (STL)

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The ____ typedef iterators is common to all containers.

A) random_access

B) bidirectional

C) pointer

D) forward

Q2) The ____ operation removes the first element from the deque object deq.

A) deq.front()

B) deq.push_front()

C) deq.pop_front()

D) deq.push()

Q3) ____________________ predicates check a specific property for a single argument.

Q4) Output iterators can be used to iterate over a range twice.

A)True

B)False

Q5) The name of the class that implements the vector container is container.

A)True

B)False

Q6) The term ____________________ stands for double-ended queue.

Q7) The operator ____________________,supported by the queue container class,removes the next element in the queue.

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

Turn static files into dynamic content formats.

Create a flipbook
Intermediate Programming with C++ Exam Bank - 1050 Verified Questions by Quizplus - Issuu