Deck 10: Defining Classes
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
Play
Full screen (f)
Deck 10: Defining Classes
1
The double colon ::)is known as the __________ operator.
scope resolution operator
2
A structure can only be passed to a function as a call-by-value parameter
False
3
A function may return a structure.
True
4
Different class may not have member functions with the same name.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
All constructors for a class must be private.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
A struct variable is declared differently from a predefined type such as an int.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
A structure definition ends with the closing brace and a _________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
Who can access private members in a class?
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
Two different structure definitions may have the same member names.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
A class member function may be private.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
A derived class is more specific than its parent,or base class.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
Class data members are almost always public.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
The assignment operator may not be used with objects of a class.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
A member function that allows the user of the class to change the value of a private data type is called a ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
A structure variable is a collection of smaller values called ____________ values
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
It is possible to have multiple private labels in a class definition.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
The keyword ________ defines a structure type definition.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
A member function that allows the user of the class to find out the value of a private data type is called a ___________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
When a structure contains another structure variable as one of its members,it is known as a ___________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
When several items variables or variables and functions)are grouped together into a single package,that is known as ______________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
If you have a class named myPersonClass,which of the following correctly declare a constructor in the class definition?
A)myPersonClass::myPersonClass);
B)myPersonClass);
C)init);
D)cast);
A)myPersonClass::myPersonClass);
B)myPersonClass);
C)init);
D)cast);
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
What is wrong with the following structure definition?
Struct MyStruct
{
Int size;
Float weight;
}
A)Nothing
B)Can not have mixed data types in a structure
C)missing semicolon
D)Braces are not needed.
Struct MyStruct
{
Int size;
Float weight;
}
A)Nothing
B)Can not have mixed data types in a structure
C)missing semicolon
D)Braces are not needed.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
A member function that gets called automatically when an object of the class is declared is called a _______________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
If class A is derived from class B,then B is a _______ of A.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
What can a constructor return? _______________
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
You specify an individual member of a struct by using
A)the assignment operator
B)an ampersand
C)an underscore
D)The dot operator
A)the assignment operator
B)an ampersand
C)an underscore
D)The dot operator
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
A Member function that allows the user of the class to see the value in a data member is known as
A)a mutator function
B)a mutation
C)a manipulator function
D)an accessor function
A)a mutator function
B)a mutation
C)a manipulator function
D)an accessor function
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
To assign values to a structure variable,you use the
A)equals operator
B)assignment operator
C)extraction operator
D)less than operator
A)equals operator
B)assignment operator
C)extraction operator
D)less than operator
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
The name of a constructor is _____________
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
In a structure definition,the identifiers declared in the braces are called
A)classes
B)structs
C)member names
D)variables
A)classes
B)structs
C)member names
D)variables
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
A class in which modifications to the implementation appear to be invisible to the user of the class is known as _________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
The constructor of a class that does not have any parameters is called a __________ constructor.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
If you have a class with a member function called displayostream& out),that will send the values in the class to the parameter stream,and you need to call that function from within another member function,how would you call it to print the data to the screen? ___________________________
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
A member function that allow the user of the class to change the value in a data member is known as
A)a mutator function
B)a mutation
C)a manipulator function
D)an accessor function
A)a mutator function
B)a mutation
C)a manipulator function
D)an accessor function
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
In the following class constructor definition,the part of the header starting with a single colon is called the ________________.
BankAccount::BankAccount): balance0),interest0.0)
BankAccount::BankAccount): balance0),interest0.0)
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
A member function of a class should be made private
A)always
B)only if it will never be used
C)if it will only be used by other members of the class
D)never,it is illegal to make a member function private.
A)always
B)only if it will never be used
C)if it will only be used by other members of the class
D)never,it is illegal to make a member function private.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
If you design a class with private data members,and do not provide mutators and accessors,then
A)The private data members can still be accessed from outside the class by using the & operator
B)The data can not be changed or viewed by anyone.
C)None of the above
D)A and B
A)The private data members can still be accessed from outside the class by using the & operator
B)The data can not be changed or viewed by anyone.
C)None of the above
D)A and B
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
Which of the following is the correct function definition header for the getAge function which is a member of the Person class?
A)int getAge);
B)int getAge)
C)int Person:getAge)
D)int Person::getAge)
A)int getAge);
B)int getAge)
C)int Person:getAge)
D)int Person::getAge)
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
When defining a class,the class should be composed of the kind of values a variable of the class can contain,and
A)member functions for that class
B)the keyword private
C)other class definitions
D)nothing else
A)member functions for that class
B)the keyword private
C)other class definitions
D)nothing else
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
A class member function that automatically initializes the data members of a class is called
A)the init function
B)an operator
C)a constructor
D)a cast
A)the init function
B)an operator
C)a constructor
D)a cast
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
Member functions of a class
A)may not be in the private section
B)must be in the private section
C)may be in either section
D)can not be called in the main program
A)may not be in the private section
B)must be in the private section
C)may be in either section
D)can not be called in the main program
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
In a class,all members are ____________ by default
A)public
B)private
C)global
D)all of the above
A)public
B)private
C)global
D)all of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
Developing an ADT means that the user of your class does not have to know the details about how the class is implemented.This is known as
A)interface
B)implementation
C)testing and debugging
D)information hiding
A)interface
B)implementation
C)testing and debugging
D)information hiding
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
Data members or member functions of a class that are declared to be private may
A)only be accessed by the main program
B)only be accessed by members of the class
C)not be accessed by the class
D)are considered to be global variables
A)only be accessed by the main program
B)only be accessed by members of the class
C)not be accessed by the class
D)are considered to be global variables
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
In a struct,all members are ____________ by default
A)public
B)private
C)global
D)all of the above
A)public
B)private
C)global
D)all of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
A data type consisting of data members and operations on those members which can be used by a programmer without knowing the implementation details of the data type is called
A)an abstract definition type
B)an available data type
C)an abstract data type
D)a primitive data type
A)an abstract definition type
B)an available data type
C)an abstract data type
D)a primitive data type
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
Which of the following function declarations will accept either cout or a file stream object as its argument?
A)void output fstream &outFile);
B)void output ofstream &outFile);
C)void output ostream &outFile);
D)void output iostream &outFile);
A)void output fstream &outFile);
B)void output ofstream &outFile);
C)void output ostream &outFile);
D)void output iostream &outFile);
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
Which part of the ADT tells the programmer using it how to use it?
A)the implementation
B)the interface
C)the abstractness
D)the scope resolution
A)the implementation
B)the interface
C)the abstractness
D)the scope resolution
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
If you are designing a class for an ADT,you can tell if the class is an ADT if
A)when you change the implementation of the class,none of the rest of the program needs to change.
B)when you change the interface of the class,nothing else needs to change.
C)you change the privte part and the rest of the program using the ADT does not compile.
D)everything must be changed.
A)when you change the implementation of the class,none of the rest of the program needs to change.
B)when you change the interface of the class,nothing else needs to change.
C)you change the privte part and the rest of the program using the ADT does not compile.
D)everything must be changed.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
A derived class has access to
A)the private functions and variables of its ancestor classes
B)the public functions and variables of its ancestor classes
C)only the functions and variables defined it its class
D)none of the above
A)the private functions and variables of its ancestor classes
B)the public functions and variables of its ancestor classes
C)only the functions and variables defined it its class
D)none of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck