100% found this document useful (3 votes)
50 views

C++ Programming From Problem Analysis to Program Design 8th Edition Malik Test Bankpdf download

The document provides links to various test banks and solutions manuals for C++ programming and other subjects, including editions of 'C++ Programming From Problem Analysis to Program Design' by Malik. It includes a series of true/false and multiple-choice questions related to C++ concepts, class definitions, and member functions. The content appears to be educational material aimed at students learning C++ programming.

Uploaded by

letorsopel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
50 views

C++ Programming From Problem Analysis to Program Design 8th Edition Malik Test Bankpdf download

The document provides links to various test banks and solutions manuals for C++ programming and other subjects, including editions of 'C++ Programming From Problem Analysis to Program Design' by Malik. It includes a series of true/false and multiple-choice questions related to C++ concepts, class definitions, and member functions. The content appears to be educational material aimed at students learning C++ programming.

Uploaded by

letorsopel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

C++ Programming From Problem Analysis to Program

Design 8th Edition Malik Test Bank pdf download

https://testbankfan.com/product/c-programming-from-problem-
analysis-to-program-design-8th-edition-malik-test-bank/
We believe these products will be a great fit for you. Click
the link to download now, or visit testbankfan.com
to discover even more!

C++ Programming From Problem Analysis to Program Design


8th Edition Malik Solutions Manual

https://testbankfan.com/product/c-programming-from-problem-
analysis-to-program-design-8th-edition-malik-solutions-manual/

C++ Programming From Problem Analysis to Program Design


7th Edition Malik Test Bank

https://testbankfan.com/product/c-programming-from-problem-
analysis-to-program-design-7th-edition-malik-test-bank/

C++ Programming From Problem Analysis to Program Design


6th Edition Malik Test Bank

https://testbankfan.com/product/c-programming-from-problem-
analysis-to-program-design-6th-edition-malik-test-bank/

Forensic Accounting and Fraud Examination 2nd Edition


Hopwood Solutions Manual

https://testbankfan.com/product/forensic-accounting-and-fraud-
examination-2nd-edition-hopwood-solutions-manual/
International Economics 3rd Edition Feenstra Test Bank

https://testbankfan.com/product/international-economics-3rd-
edition-feenstra-test-bank/

Organizational Behavior 12th Edition Schermerhorn Test


Bank

https://testbankfan.com/product/organizational-behavior-12th-
edition-schermerhorn-test-bank/

Money the Financial System and the Economy 6th Edition


Hubbard Test Bank

https://testbankfan.com/product/money-the-financial-system-and-
the-economy-6th-edition-hubbard-test-bank/

Chemistry An Atoms Focused Approach 2nd Edition Gilbert


Solutions Manual

https://testbankfan.com/product/chemistry-an-atoms-focused-
approach-2nd-edition-gilbert-solutions-manual/

Essentials of Accounting for Governmental and Not for


Profit Organizations 13th Edition Copley Solutions
Manual

https://testbankfan.com/product/essentials-of-accounting-for-
governmental-and-not-for-profit-organizations-13th-edition-
copley-solutions-manual/
Physics Principles With Applications 6th Edition
Giancoli Solutions Manual

https://testbankfan.com/product/physics-principles-with-
applications-6th-edition-giancoli-solutions-manual/
Name: Class: Date:

Chapter 10
1. A class is an example of a structured data type.
a. True
b. False
ANSWER: True
POINTS: 1
REFERENCES: 652
QUESTION TYPE: True / False
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

2. In C++, class is a reserved word and it defines only a data type.


a. True
b. False
ANSWER: True
POINTS: 1
REFERENCES: 653
QUESTION TYPE: True / False
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

3. If the heading of a member function of a class ends with the word const, then the function member cannot modify the
private member variables, but it can modify the public member variables.
a. True
b. False
ANSWER: False
POINTS: 1
REFERENCES: 655
QUESTION TYPE: True / False
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

4. In C++ terminology, a class object is the same as a class instance.


a. True
b. False
ANSWER: True
POINTS: 1
REFERENCES: 656
QUESTION TYPE: True / False
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
Copyright Cengage Learning. Powered by Cognero. Page 1
Name: Class: Date:

Chapter 10
DATE MODIFIED: 10/5/2016 1:41 PM

5. Given this declaration:


class myClass
{
public:
void print(); //Output the value of x;
MyClass();

private:
int x;
};

myClass myObject;

The following statement is legal.


myObject.x = 10;
a. True
b. False
ANSWER: False
POINTS: 1
REFERENCES: 657
QUESTION TYPE: True / False
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/30/2016 12:12 PM

6. 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
ANSWER: True
POINTS: 1
REFERENCES: 657
QUESTION TYPE: True / False
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

7. If an object is created in a user program, then the object can access both the public and private members of the
class.
a. True
b. False
ANSWER: False
POINTS: 1

Copyright Cengage Learning. Powered by Cognero. Page 2


Name: Class: Date:

Chapter 10
REFERENCES: 657
QUESTION TYPE: True / False
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

8. You can use arithmetic operators to perform arithmetic operations on class objects.
a. True
b. False
ANSWER: False
POINTS: 1
REFERENCES: 659
QUESTION TYPE: True / False
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

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


a. True
b. False
ANSWER: False
POINTS: 1
REFERENCES: 660
QUESTION TYPE: True / False
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

10. The public members of a class must be declared before the private members.
a. True
b. False
ANSWER: False
POINTS: 1
REFERENCES: 670
QUESTION TYPE: True / False
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

11. The components of a class are called the ____ of the class.
a. elements b. members
c. objects d. properties
ANSWER: b
Copyright Cengage Learning. Powered by Cognero. Page 3
Name: Class: Date:

Chapter 10
POINTS: 1
REFERENCES: 652
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

12. Which of the following class definitions is correct in C++?

a. class studentType
{
public:
void setData(string, double, int);
private:
string name;
};

b. class studentType
{
public:
void setData(string, double, int);
void print() const;
private:
string name;
double gpa;
}

c. class studentType
{
public void setData(string, double, int);
private string name;
};

d. studentType class
{
public: void setData(string, double, int);
private: string name;
};

ANSWER: a
POINTS: 1
REFERENCES: 654
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

13. If a member of a class is ____, you cannot access it outside the class.
Copyright Cengage Learning. Powered by Cognero. Page 4
Name: Class: Date:

Chapter 10
a. public b. automatic
c. private d. static
ANSWER: c
POINTS: 1
REFERENCES: 654
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

14. A class and its members can be described graphically using a notation known as the ____ notation.
a. OON b. OOD
c. UML d. OOP
ANSWER: c
POINTS: 1
REFERENCES: 656
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

clockType
-hr: int
-min: int
-sec: int
+setTime(int, int, int): void
+getTime(int&, int&, int&) const: void
+printTime() const: void
+incrementSeconds(): int
+incrementMinutes(): int
+incrementHours(): int
+equalTime(const clockType&) const: bool

15. The word ____ at the end of several the member functions in the accompanying figure class clockType specifies
that these functions cannot modify the member variables of a clockType object.
a. static b. const
c. automatic d. private
ANSWER: b
POINTS: 1
REFERENCES: 655
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
PREFACE NAME: clockType definition
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM
Copyright Cengage Learning. Powered by Cognero. Page 5
Name: Class: Date:

Chapter 10

16. Consider the UML class diagram shown in the accompanying figure. Which of the following is the name of the class?
a. clock b. clockType
c. Type d. +clockType
ANSWER: b
POINTS: 1
REFERENCES: 656
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
PREFACE NAME: clockType definition
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

17. Consider the UML class diagram shown in the accompanying figure. According to the UML class diagram, how many
private members are in the class?
a. none b. zero
c. two d. three
ANSWER: d
POINTS: 1
REFERENCES: 656
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
PREFACE NAME: clockType definition
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

18. A ____ sign in front of a member name on a UML diagram indicates that this member is a public member.
a. + b. -
c. # d. $
ANSWER: a
POINTS: 1
REFERENCES: 656
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

19. A ____ sign in front of a member name on a UML diagram indicates that this member is a protected member.
a. + b. -
c. # d. $
ANSWER: c
POINTS: 1
REFERENCES: 656
Copyright Cengage Learning. Powered by Cognero. Page 6
Name: Class: Date:

Chapter 10
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

class rectangleType
{
public:
void setLengthWidth(double x, double y);
//Postcondition: length = x; width = y;
void print() const;
//Output length and width;
double area();
//Calculate and return the area of the rectangle;
double perimeter();
//Calculate and return the parameter;
rectangleType();
//Postcondition: length = 0; width = 0;
rectangleType(double x, double y);
//Postcondition: length = x; width = y;

private:
double length;
double width;
};

20. Consider the accompanying class definition. Which of the following variable declarations is correct?
a. rectangle rectangleType;
b. class rectangleType rectangle;
c. rectangleType rectangle;
d. rectangle rectangleType.area;
ANSWER: c
POINTS: 1
REFERENCES: 657
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
PREFACE NAME: rectangleType class
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

21. Consider the accompanying class definition, and the declaration:

rectangleType bigRect;

Which of the following statements is correct?


a. rectangleType.print(); b. rectangleType::print();
c. bigRect.print(); d. bigRect::print();
ANSWER: c
Copyright Cengage Learning. Powered by Cognero. Page 7
Name: Class: Date:

Chapter 10
POINTS: 1
REFERENCES: 657
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
PREFACE NAME: rectangleType class
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

22. Consider the accompanying class definition, and the object declaration:

rectangleType bigRect(14,10);

Which of the following statements is correct?


a. bigRect.setLengthWidth();
b. bigRect.setLengthWidth(3.0, 2.0);
c. bigRect.length = 2.0;
d. bigRect.length = bigRect.width;
ANSWER: b
POINTS: 1
REFERENCES: 658
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
PREFACE NAME: rectangleType class
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

23. In C++, the ____ is called the member access operator.


a. . b. ,
c. :: d. #
ANSWER: a
POINTS: 1
REFERENCES: 657
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

24. A class object can be ____. That is, it is created each time the control reaches its declaration, and destroyed when
the control exits the surrounding block.
a. static b. automatic
c. local d. public
ANSWER: b
POINTS: 1

Copyright Cengage Learning. Powered by Cognero. Page 8


Name: Class: Date:

Chapter 10
REFERENCES: 660
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

25. 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
ANSWER: a
POINTS: 1
REFERENCES: 660
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

26. In C++, you can pass a variable by reference and still prevent the function from changing its value by using the
keyword ____ in the formal parameter declaration.
a. automatic b. private
c. static d. const
ANSWER: d
POINTS: 1
REFERENCES: 660
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

27. In C++, the scope resolution operator is ____.


a. : b. ::
c. $ d. .
ANSWER: b
POINTS: 1
REFERENCES: 662
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

28. A member function of a class that only accesses the value(s) of the data member(s) is called a(n) ____ function.
a. accessor b. mutator

Copyright Cengage Learning. Powered by Cognero. Page 9


Name: Class: Date:

Chapter 10
c. constructor d. destructor
ANSWER: a
POINTS: 1
REFERENCES: 666
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

29. To guarantee that the member variables of a class are initialized, you use ____.
a. accessors b. mutators
c. constructors d. destructor
ANSWER: c
POINTS: 1
REFERENCES: 671
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

class secretType
{
public:
static int count;
static int z;

secretType();
secretType(int a);
void print();
static void incrementY();

private:
int x;
static int y;
};

secretType::secretType()
{
x = 1;
}

secretType::secretType(int a)
{
x = a;
}

void secretType::print()
{
Copyright Cengage Learning. Powered by Cognero. Page 10
Name: Class: Date:

Chapter 10
cout << "x = " << x << ", y = " << y
<< "z = " << z
<< ", count = " << count << endl;
}

static void secretType::incrementY()


{
y++;
}

30. Consider the accompanying class and member functions definitions. How many constructors are present in the class
definition?
a. none b. one
c. two d. three
ANSWER: c
POINTS: 1
REFERENCES: 672
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
PREFACE NAME: secretType class
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

31. How many destructors can a class have?


a. no explicit destructors b. one
c. two d. any number
ANSWER: b
POINTS: 1
REFERENCES: 681
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/30/2016 12:15 PM

32. A destructor has the character ____, followed by the name of the class.
a. . b. ::
c. # d. ˜
ANSWER: d
POINTS: 1
REFERENCES: 681
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

Copyright Cengage Learning. Powered by Cognero. Page 11


Name: Class: Date:

Chapter 10
33. What does ADT stand for?
a. abstract definition type b. asynchronous data transfer
c. abstract data type d. alternative definition type
ANSWER: c
POINTS: 1
REFERENCES: 682
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

34. Which of the following is true about classes and structs?


a. By default, all members of a struct are public and all members of a class are private.
b. A struct variable is passed by value only, and a class variable is passed by reference only.
c. An assignment operator is allowed on class variables, but not on struct variables.
d. You cannot use the member access specifier private in a struct.
ANSWER: a
POINTS: 1
REFERENCES: 685
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

35. If a function of a class is static, it is declared in the class definition using the keyword static in its ____.
a. return type b. parameters
c. heading d. main function
ANSWER: c
POINTS: 1
REFERENCES: 701
QUESTION TYPE: Multiple Choice
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

36. With ____________________ functions, the definitions of the member functions are placed in the implementations
file.
ANSWER: inline
POINTS: 1
REFERENCES: 700
QUESTION TYPE: Completion
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
Copyright Cengage Learning. Powered by Cognero. Page 12
Name: Class: Date:

Chapter 10
DATE MODIFIED: 10/30/2016 12:22 PM

37. If a class object is passed by ____________________, the contents of the member variables of the actual parameter
are copied into the corresponding member variables of the formal parameter.
ANSWER: value
POINTS: 1
REFERENCES: 660
QUESTION TYPE: Completion
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

38. Non-static member variables of a class are called the ____________________ variables of the class.
ANSWER: instance
POINTS: 1
REFERENCES: 666
QUESTION TYPE: Completion
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

39. A program or software that uses and manipulates the objects of a class is called a(n) ____________________ of that
class.
ANSWER: client
POINTS: 1
REFERENCES: 666
QUESTION TYPE: Completion
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

40. A(n) ____________________ function of a class changes the values of the member variable(s) of the class.
ANSWER: mutator
POINTS: 1
REFERENCES: 666
QUESTION TYPE: Completion
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

41. A(n) ____________________ contains the definitions of the functions to implement the operations of an object.
ANSWER: implementation file
POINTS: 1
REFERENCES: 686
Copyright Cengage Learning. Powered by Cognero. Page 13
Name: Class: Date:

Chapter 10
QUESTION TYPE: Completion
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

42. The header file is also known as the ____________________.


ANSWER: interface file
interface
POINTS: 1
REFERENCES: 686
QUESTION TYPE: Completion
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

43. A(n) ____________________ is a statement specifying the condition(s) that must be true before the function is called.
ANSWER: precondition
POINTS: 1
REFERENCES: 687
QUESTION TYPE: Completion
HAS VARIABLES: False
DATE CREATED: 10/5/2016 1:41 PM
DATE MODIFIED: 10/5/2016 1:41 PM

Copyright Cengage Learning. Powered by Cognero. Page 14


Random documents with unrelated
content Scribd suggests to you:
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
Project Gutenberg™ eBooks are often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.

You might also like