Deck 3: Introduction to Classes, Objects and Strings

ملء الشاشة (f)
exit full mode
سؤال
C++ Standard Library function getline, from the header, reads characters up to, but not including, a(n)________ (which is discarded), then places the characters in a string.

A) tab
B) period
C) newline
D) \
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
A header file is typically given the filename extension:

A) .h
B) .hdr
C) .header
D) .cpp
سؤال
3.2 Q2. Which of the following statements is false?

A) Class names, member function names and data member names are all identifiers.
B) By convention, variable-name identifiers begin with an uppercase letter, and every word in the name after the first word begins with a capital letter; this naming convention is known as camel case.
C) Also by convention, class names begin with an initial uppercase letter, and member function and data member names begin with an initial lowercase letter.
D) All of the above are true.
سؤال
The ________ statement passes a value back to a function's caller.

A) recover
B) restore
C) pass
D) return
سؤال
C++ is a(n) ________ programming language because you can define new class types as needed.

A) strongly typed
B) extensible
C) inextensible
D) None of the above.
سؤال
A main function can "drive" an object by calling its member functions-without knowing how the class is implemented. In this sense, main is referred to as a(n) ________ program.

A) manipulator
B) driver
C) controller
D) operator
سؤال
Each class you create becomes a new ________ you can use to declare variables and create objects.

A) variable
B) object
C) type
D) access modifier
سؤال
The return type ________ indicates that when a function completes its task, it does not return (i.e., give back) any information to its calling function.

A) null
B) virtual
C) nullptr
D) void
سؤال
Which of the following statements is true?

A) The compiler knows about fundamental types that are "built into" C++.
B) A new type that you create is known as a user-defined type.
C) New classes, when packaged properly, can be reused by other programmers.
D) All of the above are true.
سؤال
A member-function call can supply ________ that help the function perform its task.

A) parameters
B) arguments
C) classes
D) frameworks
سؤال
Functions that are not members of a class are called ________ functions.

A) isolated
B) global
C) universal
D) general
سؤال
Assuming that text is a variable of type string, what will be the contents of text after the statement cin >> text; is executed if the user types Hello World! then presses Enter?

A) "H"
B) "Hello"
C) "Hello World"
D) "Hello World!"
سؤال
Typically, you cannot call a member function of a class until you create a(n) ________ of that class.

A) object
B) image
C) header
D) constructor
سؤال
Which of the following statements is true?

A) A class's body is enclosed in an opening left brace and a closing right brace.
B) A class definition terminates with a required semicolon.
C) Typically, each class definition is placed in a separate header with the .h filename extension.
D) All of the above are ture.
سؤال
Which of the following statements is false?

A) The number and order of arguments in a function call must match the number and order of parameters in the function definition's parameter list.
B) Every function body is delimited by an opening left brace and a closing right brace. Within the braces are one or more statements that perform the function's task(s).
C) When program execution reaches a function's closing brace, the function returns to its caller.
D) None of the above is false.
سؤال
Which of the following statements is false?

A) Variables declared in a particular function's body are local variables, which can be used only in that function.
B) When a function terminates, the values of its local variables are preserved.
C) A function's parameters also are local variables of that function.
D) The argument types in the member function call must be consistent with the types of the corresponding parameters in the member function's definition.
سؤال
To call a member function for a specific object, you specify the object's name, followed by a(n) ________, then the member function name and a set of parentheses.

A) dot operator
B) colon
C) ::
D) ->
سؤال
Files ending in .cpp are known as ________ files.

A) executable
B) secure C++
C) source-code
D) class
سؤال
Which of the following statements is false?

A) Each object of a class shares one copy of the class's data members.
B) An object's data members exist before a program calls member functions on an object, while they are executing and after the member functions complete execution.
C) Data members are declared inside a class definition but outside its member functions' bodies.
D) Headers should never contain using directives or using declarations.
سؤال
The default value for a string is ________.

A) null
B) void
C) blanks
D) the empty string
سؤال
Which of the following statements is false?

A) The default constructor does not initialize the class's fundamental-type data members, but does call the default constructor for each data member that's an object of another class.
B) A string's default constructor initializes the object to the empty string.
C) An uninitialized fundamental-type variable is implicitly initialized to zero.
D) If a class defines a constructor, the compiler will not create a default constructor for that class.
سؤال
Which of the following statements is false?

A) Each class can define a constructor for custom object initialization.
B) A constructor is a special member function that must have the same name as the class.
C) C++ requires a constructor call for every object that's created.
D) A constructor cannot specify parameters.
سؤال
Which of the following statements is false?

A) A constructor that specifies a single parameter should be declared implicit.
B) A constructor does not specify a return type, because constructors cannot return values.
C) Constructors cannot be declared const (because initializing an object modifies it).
D) None of the above statements is false.
سؤال
Which of the following statements is false?

A) Variables or functions listed after the public access specifier (and before the next access specifier, if there is one) are "available to the public." They can be used by other functions in the program, and by member functions of other classes.
B) By default, everything in a class is private, unless you specify otherwise.
C) You must list an access specifier for every member.
D) Declaring data members private is known as data hiding. private data members are encapsulated (hidden) in an object and can be accessed only by member functions of the object's class.
سؤال
Normally, constructors are ________.

A) private
B) protected
C) privy
D) public
سؤال
A default constructor has how many parameters?

A) 0.
B) 1.
C) 2.
D) Variable number.
سؤال
A member function that does not, and should not, modify the object on which it's called is declared with ________ to the right of its parameter list.

A) final
B) const
C) firm
D) immutable
سؤال
Which of the following statements is false?

A) Through the use of set and get member functions, you can validate attempted modifications to private data and control how that data is presented to the caller.
B) A client of a class is any other code that calls the class's member functions.
C) Any client code can see a private data member and do whatever it wants with it, including setting it to an invalid value.
D) Tightly controlling the access to and presentation of private data can greatly reduce errors, while increasing the usability, robustness and security of your programs.
سؤال
You can initialize fundamental-type data members in their declarations. This is known as a(n) ________ initializer and was introduced in C++11.

A) explicit
B) implicit
C) global
D) in-class initializer
سؤال
Which of the following statements about UML class diagrams is false?

A) Like operations, the UML models constructors in the third compartment of a class diagram.
B) To distinguish a constructor from the class's operations, the UML requires that the word "constructor" be enclosed in guillemets and placed before the constructor's name.
C) It's customary to list constructors before other operations in the third compartment.
D) All of the above are true.
سؤال
Which of the following statements is false?

A) The keyword private is an access specifier.
B) Access specifiers are always followed by a semicolon (;).
C) A private data member is accessible only to its class's member functions.
D) Most data-member declarations appear after the private access specifier.
سؤال
Which statement about UML class diagrams is true?

A) UML class diagrams can be used to summarize a class's attributes and operations.
B) In the UML, each class is modeled in a class diagram as a rectangle with three compartments.
C) The top compartment contains the class name centered horizontally in boldface type and the middle compartment contains the class's attribute names, which correspond to the data members of a class.
D) All of the above are true.
سؤال
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.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/33
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 3: Introduction to Classes, Objects and Strings
1
C++ Standard Library function getline, from the header, reads characters up to, but not including, a(n)________ (which is discarded), then places the characters in a string.

A) tab
B) period
C) newline
D) \
C
2
A header file is typically given the filename extension:

A) .h
B) .hdr
C) .header
D) .cpp
A
3
3.2 Q2. Which of the following statements is false?

A) Class names, member function names and data member names are all identifiers.
B) By convention, variable-name identifiers begin with an uppercase letter, and every word in the name after the first word begins with a capital letter; this naming convention is known as camel case.
C) Also by convention, class names begin with an initial uppercase letter, and member function and data member names begin with an initial lowercase letter.
D) All of the above are true.
B
4
The ________ statement passes a value back to a function's caller.

A) recover
B) restore
C) pass
D) return
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
5
C++ is a(n) ________ programming language because you can define new class types as needed.

A) strongly typed
B) extensible
C) inextensible
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
6
A main function can "drive" an object by calling its member functions-without knowing how the class is implemented. In this sense, main is referred to as a(n) ________ program.

A) manipulator
B) driver
C) controller
D) operator
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
7
Each class you create becomes a new ________ you can use to declare variables and create objects.

A) variable
B) object
C) type
D) access modifier
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
8
The return type ________ indicates that when a function completes its task, it does not return (i.e., give back) any information to its calling function.

A) null
B) virtual
C) nullptr
D) void
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
9
Which of the following statements is true?

A) The compiler knows about fundamental types that are "built into" C++.
B) A new type that you create is known as a user-defined type.
C) New classes, when packaged properly, can be reused by other programmers.
D) All of the above are true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
10
A member-function call can supply ________ that help the function perform its task.

A) parameters
B) arguments
C) classes
D) frameworks
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
11
Functions that are not members of a class are called ________ functions.

A) isolated
B) global
C) universal
D) general
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
12
Assuming that text is a variable of type string, what will be the contents of text after the statement cin >> text; is executed if the user types Hello World! then presses Enter?

A) "H"
B) "Hello"
C) "Hello World"
D) "Hello World!"
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
13
Typically, you cannot call a member function of a class until you create a(n) ________ of that class.

A) object
B) image
C) header
D) constructor
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
14
Which of the following statements is true?

A) A class's body is enclosed in an opening left brace and a closing right brace.
B) A class definition terminates with a required semicolon.
C) Typically, each class definition is placed in a separate header with the .h filename extension.
D) All of the above are ture.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
15
Which of the following statements is false?

A) The number and order of arguments in a function call must match the number and order of parameters in the function definition's parameter list.
B) Every function body is delimited by an opening left brace and a closing right brace. Within the braces are one or more statements that perform the function's task(s).
C) When program execution reaches a function's closing brace, the function returns to its caller.
D) None of the above is false.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
16
Which of the following statements is false?

A) Variables declared in a particular function's body are local variables, which can be used only in that function.
B) When a function terminates, the values of its local variables are preserved.
C) A function's parameters also are local variables of that function.
D) The argument types in the member function call must be consistent with the types of the corresponding parameters in the member function's definition.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
17
To call a member function for a specific object, you specify the object's name, followed by a(n) ________, then the member function name and a set of parentheses.

A) dot operator
B) colon
C) ::
D) ->
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
18
Files ending in .cpp are known as ________ files.

A) executable
B) secure C++
C) source-code
D) class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
19
Which of the following statements is false?

A) Each object of a class shares one copy of the class's data members.
B) An object's data members exist before a program calls member functions on an object, while they are executing and after the member functions complete execution.
C) Data members are declared inside a class definition but outside its member functions' bodies.
D) Headers should never contain using directives or using declarations.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
20
The default value for a string is ________.

A) null
B) void
C) blanks
D) the empty string
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
21
Which of the following statements is false?

A) The default constructor does not initialize the class's fundamental-type data members, but does call the default constructor for each data member that's an object of another class.
B) A string's default constructor initializes the object to the empty string.
C) An uninitialized fundamental-type variable is implicitly initialized to zero.
D) If a class defines a constructor, the compiler will not create a default constructor for that class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
22
Which of the following statements is false?

A) Each class can define a constructor for custom object initialization.
B) A constructor is a special member function that must have the same name as the class.
C) C++ requires a constructor call for every object that's created.
D) A constructor cannot specify parameters.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
23
Which of the following statements is false?

A) A constructor that specifies a single parameter should be declared implicit.
B) A constructor does not specify a return type, because constructors cannot return values.
C) Constructors cannot be declared const (because initializing an object modifies it).
D) None of the above statements is false.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
24
Which of the following statements is false?

A) Variables or functions listed after the public access specifier (and before the next access specifier, if there is one) are "available to the public." They can be used by other functions in the program, and by member functions of other classes.
B) By default, everything in a class is private, unless you specify otherwise.
C) You must list an access specifier for every member.
D) Declaring data members private is known as data hiding. private data members are encapsulated (hidden) in an object and can be accessed only by member functions of the object's class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
25
Normally, constructors are ________.

A) private
B) protected
C) privy
D) public
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
26
A default constructor has how many parameters?

A) 0.
B) 1.
C) 2.
D) Variable number.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
27
A member function that does not, and should not, modify the object on which it's called is declared with ________ to the right of its parameter list.

A) final
B) const
C) firm
D) immutable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
28
Which of the following statements is false?

A) Through the use of set and get member functions, you can validate attempted modifications to private data and control how that data is presented to the caller.
B) A client of a class is any other code that calls the class's member functions.
C) Any client code can see a private data member and do whatever it wants with it, including setting it to an invalid value.
D) Tightly controlling the access to and presentation of private data can greatly reduce errors, while increasing the usability, robustness and security of your programs.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
29
You can initialize fundamental-type data members in their declarations. This is known as a(n) ________ initializer and was introduced in C++11.

A) explicit
B) implicit
C) global
D) in-class initializer
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
30
Which of the following statements about UML class diagrams is false?

A) Like operations, the UML models constructors in the third compartment of a class diagram.
B) To distinguish a constructor from the class's operations, the UML requires that the word "constructor" be enclosed in guillemets and placed before the constructor's name.
C) It's customary to list constructors before other operations in the third compartment.
D) All of the above are true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
31
Which of the following statements is false?

A) The keyword private is an access specifier.
B) Access specifiers are always followed by a semicolon (;).
C) A private data member is accessible only to its class's member functions.
D) Most data-member declarations appear after the private access specifier.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
32
Which statement about UML class diagrams is true?

A) UML class diagrams can be used to summarize a class's attributes and operations.
B) In the UML, each class is modeled in a class diagram as a rectangle with three compartments.
C) The top compartment contains the class name centered horizontally in boldface type and the middle compartment contains the class's attribute names, which correspond to the data members of a class.
D) All of the above are true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
33
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.