Deck 9: Classes

ملء الشاشة (f)
exit full mode
سؤال
A constructor can specify the return type:

A) int.
B) string.
C) void.
D) A constructor cannot specify a return type.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Which of the following preprocessor directives does not constitute part of the preprocessor wrapper?

A) #define
B) #endif
C) #ifndef
D) #include
سؤال
Member function definitions:

A) Always require the binary scope operator ::).
B) Require the binary scope operator only when being defined outside of the definition of their class.
C) Can use the binary scope operator anywhere, but become public functions.
D) Must use the binary scope operator in their function prototype.
سؤال
In the source-code file containing a class's member function definitions, each member function definition must be tied to the class definition by preceding the member function name with the class name and ::, which is known as the:

A) Member definition linker.
B) Class implementation connector.
C) Source code resolver.
D) Binary scope resolution operator.
سؤال
The compiler will implicitly create a default constructor if:

A) The class does not contain any data members.
B) The programmer specifically requests that the compiler do so.
C) The class does not define any constructors.
D) The class already defines a default constructor.
سؤال
Variables defined inside a member function of a class have:

A) File scope.
B) Class scope.
C) Block scope.
D) Class or block scope, depending on whether the binary scope resolution operator ::) is used.
سؤال
Calling a member function of an object requires which item?

A) The dot operator.
B) Open and close braces.
C) The class name.
D) None of the above.
سؤال
A header file is typically given the filename extension:

A) .h
B) .hdr
C) .header
D) .cpp
سؤال
Classes cannot:

A) Be derived from other classes.
B) Initialize data members in the class definition.
C) Be used to model attributes and behaviors of objects.
D) Include objects from other classes as members.
سؤال
When a client code programmer uses a class whose implementation is in a separate file from its interface, that implementation code is merged with the client's code during the:

A) Programming phase.
B) Compiling phase.
C) Linking phase.
D) Executing phase.
سؤال
Member access specifiers public and private) can appear:

A) In any order and multiple times.
B) In any order public first or private first) but not multiple times.
C) In any order and multiple times, if they have brackets separating each type.
D) Outside a class definition.
سؤال
Parameterized stream manipulator setfill specifies the fill character that's displayed when an output is displayed in a field wider than the number of characters or digits in the output. The effect of setfill applies:

A) Only to the current value being displayed.
B) Only to outputs displayed in the current statement.
C) Until explicitly set to a different setting.
D) Until the output buffer is flushed.
سؤال
Assuming that Grades.h is found in the current directory and the iostream header file is found in the C++ Standard Library header file directory, which of the following preprocessor directives will fail to find its desired header file?

A) #include
B) #include "iostream"
C) #include
D) #include "Grades.h"
سؤال
Attributes of a class are also known as:

A) Constructors.
B) Local variables.
C) Data members.
D) Classes.
سؤال
When compiling a class's source code file which does not contain a main function), the information in the class's header file is used for all of the following, except:

A) Ensuring that the header of each member function matches its prototype.
B) Ensuring that each member function knows about the class's data members and other member functions.
C) Determining the correct amount of memory to allocate for each object of the class.
D) All of the above are uses that the compiler has for the header file information.
سؤال
A class-scope variable hidden by a block-scope variable can be accessed by preceding the variable name with the class name followed by:

A) ::
B) :
C) .
D) ->
سؤال
A default constructor has how many parameters?

A) 0.
B) 1.
C) 2.
D) Variable number.
سؤال
All of the following are true about classes, except:

A)Classes have attributes and behaviors.
B)The first class in any C++ program is main.
C)An object must be created from a class before it can be used.
D)A class's functions hide from the user the complex tasks they perform.
سؤال
In the UML, the top compartment of the rectangle modeling a class contains:

A) The class's name.
B) The class's attributes.
C) The class's behaviors.
D) All of the above.
سؤال
Every object of the same class:

A) Gets a copy of every member function and member variable.
B) Gets a copy of every member variable.
C) Gets a copy of every member function.
D) Shares pointers to all member variables and member functions.
سؤال
What type of member functions allow a client of a class to assign values to private data members?

A) Client member functions.
B) Get member functions.
C) Set member functions.
D) None of the above.
سؤال
If a member function of a class already provides all or part of the functionality required by a constructor or another member function then:

A) Copy and paste that member function's code into this constructor or member function.
B) Call that member function from this constructor or member function.
C) That member function is unnecessary.
D) This constructor or member function is unnecessary.
سؤال
A default constructor:

A) Is a constructor that must receive no arguments.
B) Is the constructor generated by the compiler when no constructor is provided by the programmer.
C) Does not perform any initialization.
D) Both a) and b).
سؤال
The type of function a client would use to check the balance of a bank account would be:

A) A utility function.
B) A predicate function.
C) An access function.
D) A constructor.
سؤال
Utility functions:

A) Are private member functions that support operations of the class's other member functions.
B) Are part of a class's interface.
C) Are intended to be used by clients of a class.
D) Are a type of constructor.
سؤال
Given the class definition:
Class CreateDestroy
{
Public:
CreateDestroy) { cout << "constructor called, "; }
~CreateDestroy) { cout << "destructor called, "; }
};
What will the following program output?
Int main)
{
For int i = 1; i <= 2; i++ )
CreateDestroy cd;
Return 0;
}

A) constructor called, destructor called, constructor called, destructor called,
B) constructor called, constructor called,
C) constructor called, constructor called, destructor called, destructor called,
D) Nothing.
سؤال
Which of the following statements is false?

A) Always try to localize the effects of changes to a class' data members by accessing and manipulating the data members through their set and get functions.
B) Services useful to the client should typically be provided in the class' private interface. Change is the rule rather than the exception. You should anticipate that your code will be modified.
C) Providing public set and get functions does allow clients of the class to access hidden data, but only indirectly.
سؤال
Which of the following statements is not true of a constructor and destructor of the same class?

A) They both have the same name aside from the tilde ~) character.
B) They are both usually called once per object created.
C) They both are able to have default arguments.
D) Both are called automatically, even if they are not explicitly defined in the class.
سؤال
When independent software vendors provide class libraries to clients, they typically give the __________ for the class's interface and the __________ for the class's implementation.

A) Source code file, source code file.
B) Source code file, object file.
C) Object file, source code file.
D) Object file, object file.
سؤال
A client changing the values of private data members is:

A) Only possible by calling private member functions.
B) Possible using public functions and references.
C) Never possible.
D) Only possible if the private variables are not declared inside the class.
سؤال
Returning references to non-const, private data:

A) Allows private functions to be modified.
B) Is only dangerous if the binary scope resolution operator ::) is used in the function prototype.
C) Allows private member variables to be modified, thus "breaking encapsulation."
D) Results in a compiler error.
سؤال
Which of the following statements is not true of a destructor?
a. It performs termination housekeeping.
b. It's called before the system reclaims the object's memory.
c. If the programmer does not explicitly provide a destructor, the compiler creates an "empty" destructor.
d. It releases the object's memory.
سؤال
The assignment operator =) can be used to:

A) Test for equality.
B) Copy data from one object to another.
C) Compare two objects.
D) Copy a class' member functions.
سؤال
Given the class definition:
Class CreateDestroy
{
Public:
CreateDestroy) { cout << "constructor called, "; }
~CreateDestroy) { cout << "destructor called, "; }
};
What will the following program output?
Int main)
{
CreateDestroy c1;
CreateDestroy c2;
Return 0;
}

A) constructor called, destructor called, constructor called, destructor called,
B) constructor called, destructor called,
C) constructor called, constructor called,
D) constructor called, constructor called, destructor called, destructor called,
سؤال
Which of the following statements about separating a class's interface and implementation is not true?

A) Inline member function definitions are included in the header file.
B) Changes in the class's interface will affect the client.
C) Private data members are included in the header file.
D) Changes in the class's implementation will affect the client.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/35
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 9: Classes
1
A constructor can specify the return type:

A) int.
B) string.
C) void.
D) A constructor cannot specify a return type.
D
2
Which of the following preprocessor directives does not constitute part of the preprocessor wrapper?

A) #define
B) #endif
C) #ifndef
D) #include
D
3
Member function definitions:

A) Always require the binary scope operator ::).
B) Require the binary scope operator only when being defined outside of the definition of their class.
C) Can use the binary scope operator anywhere, but become public functions.
D) Must use the binary scope operator in their function prototype.
B
4
In the source-code file containing a class's member function definitions, each member function definition must be tied to the class definition by preceding the member function name with the class name and ::, which is known as the:

A) Member definition linker.
B) Class implementation connector.
C) Source code resolver.
D) Binary scope resolution operator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
5
The compiler will implicitly create a default constructor if:

A) The class does not contain any data members.
B) The programmer specifically requests that the compiler do so.
C) The class does not define any constructors.
D) The class already defines a default constructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
6
Variables defined inside a member function of a class have:

A) File scope.
B) Class scope.
C) Block scope.
D) Class or block scope, depending on whether the binary scope resolution operator ::) is used.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
7
Calling a member function of an object requires which item?

A) The dot operator.
B) Open and close braces.
C) The class name.
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
8
A header file is typically given the filename extension:

A) .h
B) .hdr
C) .header
D) .cpp
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
9
Classes cannot:

A) Be derived from other classes.
B) Initialize data members in the class definition.
C) Be used to model attributes and behaviors of objects.
D) Include objects from other classes as members.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
10
When a client code programmer uses a class whose implementation is in a separate file from its interface, that implementation code is merged with the client's code during the:

A) Programming phase.
B) Compiling phase.
C) Linking phase.
D) Executing phase.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
11
Member access specifiers public and private) can appear:

A) In any order and multiple times.
B) In any order public first or private first) but not multiple times.
C) In any order and multiple times, if they have brackets separating each type.
D) Outside a class definition.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
12
Parameterized stream manipulator setfill specifies the fill character that's displayed when an output is displayed in a field wider than the number of characters or digits in the output. The effect of setfill applies:

A) Only to the current value being displayed.
B) Only to outputs displayed in the current statement.
C) Until explicitly set to a different setting.
D) Until the output buffer is flushed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
13
Assuming that Grades.h is found in the current directory and the iostream header file is found in the C++ Standard Library header file directory, which of the following preprocessor directives will fail to find its desired header file?

A) #include
B) #include "iostream"
C) #include
D) #include "Grades.h"
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
14
Attributes of a class are also known as:

A) Constructors.
B) Local variables.
C) Data members.
D) Classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
15
When compiling a class's source code file which does not contain a main function), the information in the class's header file is used for all of the following, except:

A) Ensuring that the header of each member function matches its prototype.
B) Ensuring that each member function knows about the class's data members and other member functions.
C) Determining the correct amount of memory to allocate for each object of the class.
D) All of the above are uses that the compiler has for the header file information.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
16
A class-scope variable hidden by a block-scope variable can be accessed by preceding the variable name with the class name followed by:

A) ::
B) :
C) .
D) ->
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
17
A default constructor has how many parameters?

A) 0.
B) 1.
C) 2.
D) Variable number.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
18
All of the following are true about classes, except:

A)Classes have attributes and behaviors.
B)The first class in any C++ program is main.
C)An object must be created from a class before it can be used.
D)A class's functions hide from the user the complex tasks they perform.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
19
In the UML, the top compartment of the rectangle modeling a class contains:

A) The class's name.
B) The class's attributes.
C) The class's behaviors.
D) All of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
20
Every object of the same class:

A) Gets a copy of every member function and member variable.
B) Gets a copy of every member variable.
C) Gets a copy of every member function.
D) Shares pointers to all member variables and member functions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
21
What type of member functions allow a client of a class to assign values to private data members?

A) Client member functions.
B) Get member functions.
C) Set member functions.
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
22
If a member function of a class already provides all or part of the functionality required by a constructor or another member function then:

A) Copy and paste that member function's code into this constructor or member function.
B) Call that member function from this constructor or member function.
C) That member function is unnecessary.
D) This constructor or member function is unnecessary.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
23
A default constructor:

A) Is a constructor that must receive no arguments.
B) Is the constructor generated by the compiler when no constructor is provided by the programmer.
C) Does not perform any initialization.
D) Both a) and b).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
24
The type of function a client would use to check the balance of a bank account would be:

A) A utility function.
B) A predicate function.
C) An access function.
D) A constructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
25
Utility functions:

A) Are private member functions that support operations of the class's other member functions.
B) Are part of a class's interface.
C) Are intended to be used by clients of a class.
D) Are a type of constructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
26
Given the class definition:
Class CreateDestroy
{
Public:
CreateDestroy) { cout << "constructor called, "; }
~CreateDestroy) { cout << "destructor called, "; }
};
What will the following program output?
Int main)
{
For int i = 1; i <= 2; i++ )
CreateDestroy cd;
Return 0;
}

A) constructor called, destructor called, constructor called, destructor called,
B) constructor called, constructor called,
C) constructor called, constructor called, destructor called, destructor called,
D) Nothing.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
27
Which of the following statements is false?

A) Always try to localize the effects of changes to a class' data members by accessing and manipulating the data members through their set and get functions.
B) Services useful to the client should typically be provided in the class' private interface. Change is the rule rather than the exception. You should anticipate that your code will be modified.
C) Providing public set and get functions does allow clients of the class to access hidden data, but only indirectly.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
28
Which of the following statements is not true of a constructor and destructor of the same class?

A) They both have the same name aside from the tilde ~) character.
B) They are both usually called once per object created.
C) They both are able to have default arguments.
D) Both are called automatically, even if they are not explicitly defined in the class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
29
When independent software vendors provide class libraries to clients, they typically give the __________ for the class's interface and the __________ for the class's implementation.

A) Source code file, source code file.
B) Source code file, object file.
C) Object file, source code file.
D) Object file, object file.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
30
A client changing the values of private data members is:

A) Only possible by calling private member functions.
B) Possible using public functions and references.
C) Never possible.
D) Only possible if the private variables are not declared inside the class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
31
Returning references to non-const, private data:

A) Allows private functions to be modified.
B) Is only dangerous if the binary scope resolution operator ::) is used in the function prototype.
C) Allows private member variables to be modified, thus "breaking encapsulation."
D) Results in a compiler error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
32
Which of the following statements is not true of a destructor?
a. It performs termination housekeeping.
b. It's called before the system reclaims the object's memory.
c. If the programmer does not explicitly provide a destructor, the compiler creates an "empty" destructor.
d. It releases the object's memory.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
33
The assignment operator =) can be used to:

A) Test for equality.
B) Copy data from one object to another.
C) Compare two objects.
D) Copy a class' member functions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
34
Given the class definition:
Class CreateDestroy
{
Public:
CreateDestroy) { cout << "constructor called, "; }
~CreateDestroy) { cout << "destructor called, "; }
};
What will the following program output?
Int main)
{
CreateDestroy c1;
CreateDestroy c2;
Return 0;
}

A) constructor called, destructor called, constructor called, destructor called,
B) constructor called, destructor called,
C) constructor called, constructor called,
D) constructor called, constructor called, destructor called, destructor called,
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
35
Which of the following statements about separating a class's interface and implementation is not true?

A) Inline member function definitions are included in the header file.
B) Changes in the class's interface will affect the client.
C) Private data members are included in the header file.
D) Changes in the class's implementation will affect the client.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.