Introduction to C++ Test Preparation - 1050 Verified Questions

Page 1


Introduction to C++ Test Preparation

Course Introduction

Introduction to C++ is a foundational course aimed at students who wish to learn the basics of programming using the C++ language. The course covers fundamental programming concepts such as variables, data types, control structures, functions, arrays, and pointers. Students will develop problem-solving skills as they write, test, and debug simple C++ programs. Emphasis is placed on understanding object-oriented principles, including classes, objects, inheritance, and polymorphism, to prepare students for more advanced programming challenges. By the end of the course, learners will be equipped with a solid understanding of C++ syntax and essential programming techniques, enabling them to apply these skills in academic or professional settings.

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 digit 0 or 1 is called a binary digit,or ____.

A) bit

B) bytecode

C) Unicode

D) hexcode

Answer: A

Q2) Main memory is called ____.

A) read only memory

B) random access memory

C) read and write memory

D) random read only memory

Answer: B

Q3) To develop a program to solve a problem,you start by analyzing the problem.

A)True

B)False

Answer: True

Q4) In object-oriented design,the first step in the problem-solving process is to identify the components called ____________________,which form the basis of the solution,and to determine how they interact with one another.

Answer: objects

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

Sample Questions

Q1) ____________________ rules determine the meaning of instructions.

Answer: Semantic semantic

Q2) Suppose that alpha and beta are int variables.The statement alpha = beta++; is equivalent to the statement(s)____.

A) alpha = 1 + beta;

B) alpha = alpha + beta;

C) alpha = beta;

Beta = beta + 1;

D) beta = beta + 1;

Alpha = beta;

Answer: C

Q3) ____ are executable statements that inform the user what to do.

A) Variables

B) Prompt lines

C) Named constants

D) Expressions

Answer: B

Q4) The maximum number of significant digits is called the ____________________.

Answer: precision

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) Manipulators without parameters are part of the ____ header file.

A) iostream

B) iomanip

C) ifstream

D) pmanip

Answer: A

Q2) Suppose that x is an int variable,y is a double variable and ch is a char variable and the input is: 15A 73.2

Choose the values after the following statement executes:

Cin >> x >> ch >> y;

A) x = 15, ch = 'A', y = 73.2

B) x = 15, ch = 'A', y = 73.0

C) x = 15, ch = 'a', y = 73.0

D) This statement results in an error because there is no space between 15 and A.

Answer: A

Q3) The manipulator ____________________ is used to output the value of an expression in a specific number of columns.

Answer: setw

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

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) Assume you have three int variables: x = 2,y = 6,and z.Choose the value of z in the following expression: z = (y / x > 0)? x : y;.

A) 2

B) 3

C) 4

D) 6

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

Q3) In C++,the logical operator AND is represented by ____________________.

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

Sample Questions

Q1) In a sentinel-controlled while loop,the body of the loop continues to execute until the EOF symbol is read.

A)True

B)False

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

Q3) Which of the following statements generates a random number between 0 and 50?

A) srand(time(0));

Num = rand() % 50;

B) srand(time(10));

Num = rand()/50;

C) srand(time(0));

Num = rand()50;

D) srand(time(10));

Num = rand() % 50;

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

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

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

Q7) The function eof is a member of the data type ____________________.

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) The program that tests a function is called a(n)____________________ program.

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

Q3) A(n)____________________ parameter s a formal parameter that receives a copy of the content of the corresponding actual parameter.

Q4) Given the following function: int strange(int x,int y) {

\(\quad\)if (x > y)

\(\quad\)\(\quad\)Return x + y; else

\(\quad\)Return x - y; }

What is the output of the following statement? Cout << strange(4,5)<< endl; A) -1

B) 1

C) 9 D) 20

Q5) The ____________________ of a function consists of the function name and its formal parameter list.

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

Sample Questions

Q1) In C++,namespace is a reserved word.

A)True

B)False

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

A) 1996

B) 1998

C) 1999

D) 2000

Q3) The string expression strVar.____________________ inserts all the characters of str at index pos into strVar.

Q4) Suppose str = "xyzw";.After the statement str[2] = 'Y'; The value of str is "____".

A) xyzw

B) xYzw

C) xyYw

D) xzYw

Q5) In ANSI/ISO Standard C++,the ____________________ mechanism was designed to solve the problem of overlapping global identifiers.

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

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

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) Assume you have the following declaration int beta[50];.Which of the following is a valid element of beta?

A) beta['2']

B) beta['50']

C) beta[0]

D) beta[50]

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

Q3) Which of the following correctly declares name to be a character array and stores "William" in it?

A) char name[6] = "William";

B) char name[7] = "William";

C) char name[8] = "William";

D) char name[8] = 'William';

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

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

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) Consider the following statements: struct supplierType { \(\quad\)String name; \(\quad\)Int supplierID; }; struct applianceType { \(\quad\)supplierType supplier; \(\quad\)string modelNo; \(\quad\)double cost; };

applianceType applianceList[25];

Which of the following best describes applianceList?

A) It is a multidimensional array.

B) It is a struct.

C) It is an array of structs.

D) It is a struct of arrays.

Q2) Memory is allocated for struct variables only when you ____________________ them.

Q3) Arrays are passed by ____________________ only.

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) A(n)____________________ is a statement specifying the condition(s)that must be true before the function is called.

Q2) A class and its members can be described graphically using a notation known as the ____ notation.

A) OON

B) OOD

C) UML

D) OOP

Q3) What does ADT stand for?

A) abstract definition type

B) asynchronous data transfer

C) abstract data type

D) alternative definition type

Q4) You can use arithmetic operators to perform arithmetic operations on class objects.

A)True

B)False

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

Q6) The header file is also known as the ____________________.

Q7) Classes were specifically designed in C++ to handle ____________________.

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

Sample Questions

Q1) If the derived class classD overrides a public member function functionName of the base class classB,then to specify a call to that public member function of the base class you use the statement ____.

A) classD::functionName();

B) classB::functionName();

C) classD.functionName();

D) classB.functionName();

Q2) The preprocessor directive ____________________ is used to prevent multiple inclusions of a header file in a program.

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

Q4) In protected inheritance,public and protected members of the base class become the protected members of the derived class.

A)True

B)False

Q5) In multiple inheritance,the derived class has more than one base class.

A)True

B)False

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

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

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

A)True

B)False

Q3) For classes with pointer member variables,you should include the copy constructor and the ____________________ in the class.

Q4) Given the declaration int *p;

The statement p = new int[50]; dynamically allocates an array of 50 components of type int and p contains the base address of the array.

A)True

B)False

Page 14

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

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) Which of the following function prototypes overloads the != operator for the class rectangleType?

A) bool operator!=(rectangle&) const;

B) bool operator!=(const rectangleType&) const;

C) int operator!=(const rectangleType) const;

D) int operator!=(rectangle&) const;

Q2) 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.

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) Both parameters of the function to overload the operator << are reference parameters.

A)True

B)False

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

Page 15

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) Throwing an exception is typically done using the ____________________ statement.

Q2) The heading of a try block can contain ellipses in place of a parameter.

A)True

B)False

Q3) In C++,throw is a(n)____________________ word.

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

A) stdex

B) stdlib

C) stdexcept

D) exception

Q5) Which of the following options should you choose when an exception occurs in the program that analyzes an airline's ticketing transactions?

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.

Q6) One of the typical ways of dealing with exceptions is to use an if statement.

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

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Which of the following function headings can be used for a recursive definition of a function to calculate the nth Fibonacci number?

A) void rFibNum(int a, int b)

B) bool rFibNum(int a, int b)

C) bool rFibNum(int a, int b, int n)

D) int rFibNum(int a, int b, int n)

Q2) In the Tower of Hanoi problem,if needle 1 contains three disks,then the number of moves required to move all three disks from needle 1 to needle 3 is

Q3) A(n)____________________ control structure is used to control the repeated calls in recursion.

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

Q5) Let x be an integer.We call the ____________________ of x after division by 2 the rightmost bit of x.

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

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) The ____________________ operator advances the iterator to the next node in the linked list.

Q2) The deleteNode operation (if the item to be deleted is in a doubly linked list)requires the adjustment of ____ pointer(s)in certain nodes.

A) one

B) two

C) three

D) four

Q3) For classes that include pointer data members,the assignment operator must be explicitly ____________________.

Q4) Which of the following is a basic operation on singly linked lists?

A) Retrieve the data of an arbitrary node.

B) Swap the head and the last nodes.

C) Determine whether the list is full.

D) Make a copy of the linked list.

Q5) In a linked list,the ____________________ operator returns the info of the current node.

Q6) The nodes of a standard ordered list (as constructed in the text)are in ____________________ order.

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

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

Q2) ____________________ techniques are used when it is too expensive or dangerous to experiment with real systems.

Q3) You can perform the add operation,called ____,to add an element onto the stack.

A) pop

B) push

C) enqueue

D) dequeue

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) In ____________________ notation,operators are written after the operands.

Page 19

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) In a bubble sort for list of length n,the first step is to compare elements ____.

A) list[0] and list[n]

B) list[0] and list[n-1]

C) list[0] and list[1]

D) list[n-1] and list[n+1]

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

A)True

B)False

Q3) The swap function of quick sort is written differently from the swap function for selection sort.

A)True

B)False

Q4) For a list of length n,selection sort makes ____ item assignments.

A) n(n - 1)/2

B) 3(n - 1)

C) 3(n)

D) 4(n + 1)

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

Q6) A sequence of branches in a comparison tree is called a(n)____________________.

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

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The operations to do inorder,preorder,and postorder traversals of a binary search tree are the same as those for a binary tree.

A)True

B)False

Q2) Every node in a binary tree has ____ pointers.

A) one

B) two

C) three

D) four

Q3) When traversing a binary tree with the pointer current,the pointer current is initialized to ____.

A) NULL

B) llink

C) rlink

D) root

Q4) Duplicates are allowed in a binary search tree.

A)True

B)False

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

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

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 ____ of sets A and B is the set of all elements that are in A and B.

A) intersection

B) union

C) graph

D) reunion

Q2) Let G be a weighted graph.Let u and v be two vertices in G,and let P be a path in G from u to v.The weight of the path P is the sum of the weights of all the ____________________ on the path P.

Q3) A graph G is a pair,G = (V,E),where V is a finite nonempty set called the set of ____ of G,and the elements of E are the pairs of elements of V.

A) nodes

B) branches

C) vertices

D) edges

Q4) The shortest path is the path with the smallest ____.

A) length

B) index

C) weight

D) key

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

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 associated header file of the sequence container multimap is ____________________.

Q2) A container's ____ executes when the object goes out of scope.

A) default constructor

B) destructor

C) copy constructor

D) iterator

Q3) If the data needs to be processed in a(n)____ manner,use a queue.

A) FILO

B) LILO

C) LIFO

D) FIFO

Q4) The operator ____________________,supported by the stack container class,inserts a copy of item onto the stack.

Q5) 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()

Q6) List containers are implemented as doubly ____________________.

23

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

Turn static files into dynamic content formats.

Create a flipbook
Introduction to C++ Test Preparation - 1050 Verified Questions by Quizplus - Issuu