Skip to main content

C++ Classes and Data Structures Jeffrey Childs Test Bank

Page 1

C++ Classes and Data Structures By Jeffrey Childs

Email: richard@qwconsultancy.com


Chapter 1 Multiple Choice (Chapter 1) 1) In C++, a data structure is often an object that is made from a ____________. A. function B. struct C. variable D. class 2) A(n) _________ is often defined for a record of information. A. array B. struct C. function D. variable 3) The variables declared within a struct definition are called: A. components B. data members C. characteristics D. clients 4) When a programmer writes a definition to make a new type to be used for a declaration, the new type is called a: A. programmer-defined type B. client-defined type C. struct-defined type D. user-defined type 5) By convention, a _____________ includes public and private sections. A. class B. class function C. struct D. data member 6) A(n) ______________ is made from a class. A. data member B. class function C. object D. blueprint 7) hiding data from outside entities (the way the private section of a class hides data from the main program) describes ___________________. A. encapsulation B. maintenance C. poor programming practice


D. invisibility 8) The __________ section of a well-written class does not contain data members. A. private B. specification C. specification File D. public 9) The data member declarations of a class are found in the _________________. A. public section B. private section C. function definitions D. function prototypes 10) The public section of a class is also referred to as the _________________. A. class interface B. maintenance area C. data member section D. class implementation 11) ____________________ refers to how something was put into code. A. Design B. Maintenance C. Implementation D. Specification 12) The file that contains the class definition is called the ___________________. A. class implementation file B. main program file C. class specification file D. client file 13) The file that contains the class function definitions is called the ________________. A. class specification file B. header file C. main program file D. class implementation file 14) A file that has a .h extension is called a _____________________. A. main program file B. class specification file C. class implementation file D. header file 15) A _____________ is a person who makes use of a class when writing a program. A. client


B. user C. maintainer D. class specialist 16) A ________________ is a program that uses a class. A. function B. main function C. user program D. client program 17) A ________________ is used to test a class. A. class tester B. testing machine C. class interface D. test driver 18) ______________ is work done on a program after it has been put into operation. A. Class specification B. Class implementation C. Operation implementation D. Maintenance 19) When a function name, like setBalance, describes what the function does, it is an example of: A. a function prototype B. self-documenting code C. function implementation D. encapsulation 20) Suppose we have a struct called Employee, we have an object declared from the struct called emp, and we have a data member of the struct called salary. To access the salary data member of emp, we would use the code: A. emp[salary] B. Employee.emp[salary] C. emp( salary ) D. emp.salary 21) Suppose we have a class called Fish, an object of the Fish class called salmon, a class function called eat, and we would like to pass the string “worm” into the eat function. The line of code for doing this would look like this: A. Fish.eat( “worm” ); B. eat( “worm” ); C. salmon.eat( “worm” ); D. Fish.salmon( eat.worm );


22) When a main program communicates with the object of a class, the first step of the communication involves: A. a class function using its data members to prepare for the communication B. a signal sent from the main program to a class data member C. the call of a class function from the main program D. the call of a client function from the main program 23) In the past, most of the work was spent on designing, coding, and testing programs, while little work is spent on maintenance; today, most of the work on a program is spent on maintenance. The main reason for this trend is because. A. people don’t spend as much time designing as they used to B. customers complain more often today than in the past C. programmers are intentionally making programs buggier, so they can spend more time maintaining them – it’s job security D. in the past, programs were small and could easily be rewritten; now, programs are humongous, and it is more cost-effective to maintain them 24) The main advantage to declaring a variable within a class definition is that: A. you only have to declare it once B. the object made from the class will remember the value of the variable, even when a function of the object is not executing C. it allows you to write class functions to access the value of the variable D. you might declare a variable that is not useful, and the client will never know 25) The main program is often called a client program because: A. a client (computer user) uses the main program B. a class is often a client of a main program C. a single class can be used by many different main programs, so the class can be thought of as a service, while the main programs that use the service are clients D. special programmers, called clientia, write them

Answers to Multiple Choice (Chapter 1) 1) D 2) B 3) B 4) D 5) A 6) C 7) A 8) D 9) B 10) A 11) C


Turn static files into dynamic content formats.

Create a flipbook