Introduction to C++ Pre-Test Questions - 891 Verified Questions

Page 1


Introduction to C++ Pre-Test Questions

Course Introduction

Introduction to C++ is a foundational course designed to familiarize students with the fundamental concepts and syntax of the C++ programming language. Through hands-on exercises and practical examples, students will learn the basics of programming structure, data types, control statements, functions, arrays, and object-oriented programming principles such as classes and inheritance. The course also emphasizes problem-solving techniques, debugging, and the development of efficient, reliable programs. By the end of the course, students will be prepared to write and understand C++ programs, laying a strong foundation for further study in computer science and software development.

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) What statement best describes a variable and its primary purpose?

A)A variable is a structured, general-purpose language designed primarily for teaching programming.

B)A variable is a collection of eight bits.

C)A variable is a word that has a special meaning to the compiler.

D)A variable is a named storage location in the computer's memory used for holding a piece of information.

E)A variable is a "line" of code in the body of a program, which may change.

Answer: D

Q2) A(n)________ is a set of instructions that the computer follows to solve a problem.

A)Compiler

B)Linker

C)Program

D)Operator

E)None of the above

Answer: C

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

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) Floating point constants are normally stored in memory as doubles.

A)True

B)False

Answer: True

Q2) A character literal is enclosed in ________ quotation marks, whereas a string literal is enclosed in ________ quotation marks.

A)double, single

B)triple, double

C)open, closed

D)single, double

E)None of the above

Answer: D

Q3) When writing long integer literals or long long integer literals in C++ 11, you can use either an uppercase or lowercase L.

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) In C++, it is impossible to display the number 34.789 in a field of 9 spaces with 2 decimal places of precision.

A)True

B)False

Answer: False

Q2) The cin << statement will stop reading input when it encounters a newline character.

A)True

B)False

Answer: True

Q3) The following statement will output $5.00 to the screen: cout << setprecision(5)<< dollars << endl;

A)True

B)False

Answer: False

Q4) When C++ is working with an operator, it strives to convert the operands to the same type.

A)True

B)False Answer: True

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) Whereas < is called a relational operator, x < y is called a(n)________.

A)Arithmetic operator

B)Relative operator

C)Relational expression

D)Largeness test

E)None of these

Q2) This statement uses the value of a variable or expression to determine where the program will branch to.

A)switch

B)select

C)associative

D)scope

E)None of these

Q3) This operator is used in C++ to represent equality.

A)=

B)><

C)!!

D)==

E)None of these

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) Assuming outFile is a file stream object and number is a variable, which statement writes the contents of number to the file associated with outFile?

A)write(outFile, number);

B)outFile >> number;

C)outFile << number;

D)number >> outFile;

Q2) If you want a user to enter exactly 20 values, which loop would be the best to use?

A)do-while

B)for

C)while

D)infinite

E)None of these

Q3) This may be used to write information to a file.

A)cout object

B)pen object

C)output object

D)stream insertion operator

E)None of these

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

7

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) When a function is called, flow of control moves to the function's prototype.

A)True

B)False

Q2) The value in this type of local variable persists between function calls.

A)global

B)internal

C)static

D)dynamic

E)None of these

Q3) Local variables are initialized to zero by default.

A)True

B)False

Q4) It is a good programming practice to ________ your functions by writing comments that describe what they do.

A)execute

B)document C)eliminate

D)prototype

E)None of these

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

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) Unlike regular variables, these can hold multiple values.

A)constants

B)named constants

C)arrays

D)floating-point variables

E)None of these

Q2) Which statement correctly defines a vector object for holding integers?

A)vector v&lt;int&gt;;

B)int vector v;

C)int&lt;vector&gt; v;

D)vector&lt;int&gt; v;

Q3) An array of string objects that will hold 5 names would be declared using which statement?

A)string names[5];

B)string names(5);

C)string names5;

D)String[5] names;

E)None of these will work.

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) Before you can perform a selection sort, the data must be stored in ascending order.

A)True

B)False

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

A)first

B)last

C)largest

D)middle

E)None of these

Q3) Array elements must be ________ before a binary search can be performed. A)summed

B)set to zero

C)sorted

D)positive numbers

E)None of these

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

A)True

B)False

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) ________ can be used as pointers.

A)Array names

B)Numeric constants

C)Punctuation marks

D)All of these

E)None of these

Q2) Which of the following statements deletes memory that has been dynamically allocated for an array?

A)int array = delete memory;

B)int delete[ ];

C)delete [] array;

D)new array = delete;

E)None of these

Q3) It is legal to subtract a pointer variable from another pointer variable.

A)True

B)False

Q4) A pointer can be used as a function argument, giving the function access to the original argument.

A)True

B)False

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) To define a C-string that will store students' last names of up to 25 characters in length, which is an appropriate statement?

A)char lastName[25];

B)string lastName[25];

C)char lastName[26];

D)string lastName[24];

E)None of these

Q2) The C-string company[12] can hold ________.

A)twelve characters

B)thirteen characters

C)eleven characters and the null terminator

D)twelve characters and the null terminator

E)None of the above

Q3) A library function that can find one C- string inside another is:

A)strcmp

B)strstr

C)strfind

D)strsearch

E)None of these

Page 12

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

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) The names of the enumerators in an enumerated data type must be enclosed in quotation marks.

A)True

B)False

Q2) Which of the following assigns a value to the hourlyWage member of employee[2]?

A)employee[2]->hourlyWage = 50.00;

B)employee2.hourlyWage = 7.50;

C)hourlyWage[2].employee = 29.75

D)employee[2].hourlyWage = 100.00;

E)None of these

Q3) In C++ 11, if you want to retrieve a strongly typed enumerator's underlying integer value, you must use a cast operator.

A)True

B)False

Q4) It is possible to output the contents of all members of a structure variable using a cout << statement followed by the name of the structure variable.

A)True

B)False

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

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) When passing a file stream object to a function, you should always pass it by reference.

A)True

B)False

Q2) When data is read from a file, it is automatically stored in a variable.

A)True

B)False

Q3) Which statement opens a file in such a way that information will only be written to its end?

A)dataFile(open.append("info.dat"));

B)dataFile.open("info.dat", ios::out | ios::app);

C)dataFile.open = "C:\\info.dat" ios:append;

D)open(dataFile.append);

E)None of these

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

Page 14

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

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) When you dereference an object pointer, use the ________.

A)-> operator

B)<> operator

C)dot operator

D)& operator

E)None of these

Q2) Objects in an array are accessed with ________, just like any other data type in an array.

A)subscripts

B)parentheses

C)#include statements

D)output format manipulators

E)None of these

Q3) If you do not declare a destructor function, the compiler will furnish one automatically.

A)True

B)False

Q4) More than one destructor function may be defined for a class.

A)True

B)False

Page 15

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

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) When you redefine the way a standard operator works when it is used with class objects, you have ________ the operator.

A)reassigned

B)reformatted

C)overloaded

D)overwhelmed

E)None of these

Q2) When you overload an operator, you cannot change the number of ________ taken by the operator.

A)arguments

B)parameters

C)operations

D)operands

E)None of these

Q3) A good reason for overloading an operator is to enable it to ________.

A)outperform its C language counterparts

B)work in its usual way, but with programmer-defined data types

C)operate on more operands than in its standard definition

D)operate on no operands

E)None of these

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) ________ to a base class may be assigned the address of a derived class object.

A)Access specifiers

B)Static members

C)Private members

D)Pointers

E)None of these

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 these

Q3) The compiler performs ________ on virtual functions.

A)static binding

B)dynamic binding

C)additional error checking

D)no special services

E)None of these

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) Using a function template requires less code than overloading a function.

A)True

B)False

Q2) These are used to signal errors or unexpected events that occur while a program is running.

A)Virtual functions

B)Destructors

C)Exceptions

D)Templates

E)None of these

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

A)created

B)thrown

C)passed

D)ignored

E)None of these

Q4) There is no difference between declaring an object of an ordinary class and an object of a template class.

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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The Standard Template Library (STL)provides a linked list container.

A)True

B)False

Q2) To insert a new node in ascending order into a list, the list must be:

A)arranged in descending order

B)arranged in ascending order

C)randomly ordered

D)empty

Q3) ADT stands for:

A)Algorithm Dependent Template

B)Algorithm Driven Template

C)Abstract Data Type

D)Automatic Data Type

E)None of these

Q4) To append a node to a list means to ________.

A)delete a node from the beginning of the list

B)delete a node from the end of the list

C)add a node to the beginning of the list

D)add a node to the end of the list

E)None of these

Page 19

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

47 Verified Questions

47 Flashcards

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

Sample Questions

Q1) A dynamic stack starts as an empty linked list.

A)True

B)False

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

A)append

B)add

C)pop

D)push

E)None of these

Q3) Stacks are useful data structures for algorithms that work ________ with the ________ saved element in the series.

A)last, first

B)first, last

C)efficiently, first

D)efficiently, last

E)None of these

Q4) A stack that is implemented as a linked list is known as a deque.

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 QuickSort algorithm is used to sort ________.

A)lists stored in arrays or linear linked lists

B)tree data structures

C)randomly-ordered files

D)All of these

E)None of these

Q2) The QuickSort algorithm was developed in 1960 by ________.

A)Bjarne Stroustrup

B)Tony Gaddis

C)C.A.R. Hoare

D)C.M. Turner

E)None of these

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

A)True

B)False

Q4) Like a loop, a recursive function must have some method to control the number of times it repeats.

A)True

B)False

21

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

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) Binary trees are commonly used to organize key values that index database records.

A)True

B)False

Q2) The height of a tree describes how many levels there are in the tree.

A)True

B)False

Q3) Binary trees can be divided into:

A)branches

B)leaves

C)subtrees

D)sawdust

E)None of these

Q4) Dereferencing a pointer to a pointer gives you another pointer.

A)True

B)False

Q5) All nodes to the right of a node hold values greater than the node's value.

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
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.