Deck 13: Introduction to Classes
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/46
العب
ملء الشاشة (f)
Deck 13: Introduction to Classes
1
This type of member function may be called only from a function that is a member of the same class.
A) public
B) private
C) global
D) local
E) None of these
A) public
B) private
C) global
D) local
E) None of these
B
2
This type of member function may be called from a statement outside the class.
A) public
B) private
C) undeclared
D) global
E) None of these
A) public
B) private
C) undeclared
D) global
E) None of these
A
3
Objects are created from abstract data types that encapsulate _______ and _______ together.
A) numbers, characters
B) data, functions
C) addresses, pointers
D) integers, floats
E) None of these
A) numbers, characters
B) data, functions
C) addresses, pointers
D) integers, floats
E) None of these
B
4
Class declarations are usually stored here.
A) On separate disk volumes
B) In their own header files
C) In .cpp files, along with function definitions
D) Under pseudonyms
E) None of these
A) On separate disk volumes
B) In their own header files
C) In .cpp files, along with function definitions
D) Under pseudonyms
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
5
Members of a class object are accessed with the
A) dot operator.
B) cin object.
C) extraction operator.
D) stream insertion operator.
E) None of these
A) dot operator.
B) cin object.
C) extraction operator.
D) stream insertion operator.
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
6
When you dereference an object pointer, use the
A) -> operator
B) <> operator
C) dot operator
D) & operator
E) None of these
A) -> operator
B) <> operator
C) dot operator
D) & operator
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
7
This directive is used to create an "include guard," which allows a program to be conditionally compiled. This prevents a header file from accidentally being included more than once.
A) #include
B) #guard
C) #ifndef
D) #endif
E) None of these
A) #include
B) #guard
C) #ifndef
D) #endif
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
8
A C++ class is similar to one of these.
A) inline function
B) header file
C) library function
D) structure
E) None of these
A) inline function
B) header file
C) library function
D) structure
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
9
A ___________ is a member function that is automatically called when a class object is ___________.
A) destructor, created
B) constructor, created
C) static function, deallocated
D) utility function, declared
E) None of these
A) destructor, created
B) constructor, created
C) static function, deallocated
D) utility function, declared
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
10
When a constructor function accepts no arguments, or does not have to accept arguments because of default arguments, it is called a(n):
A) empty constructor
B) default constructor
C) stand-alone function
D) arbitrator function
E) None of these
A) empty constructor
B) default constructor
C) stand-alone function
D) arbitrator function
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
11
Assuming that Rectangle is a class name, the statement Rectangle *BoxPtr;
A) declares an object of class Rectangle
B) assigns the value of *BoxPtr to the object Rectangle
C) defines a Rectangle pointer variable called BoxPtr
D) is illegal in C++
E) None of these
A) declares an object of class Rectangle
B) assigns the value of *BoxPtr to the object Rectangle
C) defines a Rectangle pointer variable called BoxPtr
D) is illegal in C++
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
12
In OOP terminology, an object's member variables are often called its _________, and its member functions are sometimes referred to as its behaviors, or ____________.
A) values, morals
B) data, activities
C) attributes, activities
D) attributes, methods
E) None of these
A) values, morals
B) data, activities
C) attributes, activities
D) attributes, methods
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
13
A class is a(n) _____________ that is defined by the programmer.
A) data type
B) function
C) method
D) attribute
E) None of these
A) data type
B) function
C) method
D) attribute
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
14
When the body of a member function is defined inside a class declaration, it is said to be
A) static
B) globally
C) inline
D) conditionally
E) None of these
A) static
B) globally
C) inline
D) conditionally
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
15
If you do not declare an access specification, the default for members of a class is
A) inline
B) private
C) public
D) global
E) None of these
A) inline
B) private
C) public
D) global
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
16
The constructor function's return type is
A) int
B) float
C) char
D) structure pointer
E) None of these
A) int
B) float
C) char
D) structure pointer
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
17
The destructor function's return type is:
A) tilde
B) int
C) float
D) nothing. Destructors have no return type.
E) None of the above.
A) tilde
B) int
C) float
D) nothing. Destructors have no return type.
E) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
18
Examples of access specifiers are the keywords:
A) near and far
B) opened and closed
C) private and public
D) table and row
E) None of these
A) near and far
B) opened and closed
C) private and public
D) table and row
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
19
This is used to protect important data.
A) public access specifier
B) private access specifier
C) protect() member function
D) class protection operator, @
E) None of these
A) public access specifier
B) private access specifier
C) protect() member function
D) class protection operator, @
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
20
In a procedural program, you typically have __________stored in a collection of variables, and a set of __________ that perform operations on the data.
A) numbers, arguments
B) parameters, arguments
C) strings, operators
D) data, functions
E) None of these
A) numbers, arguments
B) parameters, arguments
C) strings, operators
D) data, functions
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
21
For the following code, which statement is not true? class Point
{
Private:
Double y;
Double z;
Public:
Double x;
};
A) x is available to code that is written outside the class.
B) The name of the class is Point.
C) x, y, and z are called members of the class.
D) z is available to code that is written outside the class.
{
Private:
Double y;
Double z;
Public:
Double x;
};
A) x is available to code that is written outside the class.
B) The name of the class is Point.
C) x, y, and z are called members of the class.
D) z is available to code that is written outside the class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
22
The constructor function always has the same name as
A) the first private data member
B) the first public data member
C) the class
D) the first object of the class
E) None of these
A) the first private data member
B) the first public data member
C) the class
D) the first object of the class
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
23
What is the output of the following program? #include
Using namespace std;
Class TestClass
{
Public:
TestClass(int x)
{ cout << x << endl; }
TestClass()
{ cout << "Hello!" << endl; }
};
Int main()
{
TestClass test;
Return 0;
}
A) The program runs, but with no output.
B) 0
C) Hello!
D) The program will not compile.
Using namespace std;
Class TestClass
{
Public:
TestClass(int x)
{ cout << x << endl; }
TestClass()
{ cout << "Hello!" << endl; }
};
Int main()
{
TestClass test;
Return 0;
}
A) The program runs, but with no output.
B) 0
C) Hello!
D) The program will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
24
More than one constructor function may be defined for a class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
25
What is the output of the following program? #include
Using namespace std;
Class TestClass
{
Private:
Int val;
Void showVal()
{ cout << val << endl; }
Public:
TestClass(int x)
{ val = x; }
};
Int main()
{
TestClass test(77);
Test.showVal();
Return 0;
}
A) The program runs, but with no output.
B) 77
C) 0
D) The program will not compile.
Using namespace std;
Class TestClass
{
Private:
Int val;
Void showVal()
{ cout << val << endl; }
Public:
TestClass(int x)
{ val = x; }
};
Int main()
{
TestClass test(77);
Test.showVal();
Return 0;
}
A) The program runs, but with no output.
B) 77
C) 0
D) The program will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
26
This is automatically called when an object is destroyed.
A) constructor function
B) specification deallocator
C) destructor function
D) coroner function
E) None of these
A) constructor function
B) specification deallocator
C) destructor function
D) coroner function
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
27
The process of object-oriented analysis can be viewed as the following steps:
A) Identify objects, then define objects' attributes, behaviors, and relationships
B) Define data members and member functions, then assign a class name
C) Declare private and public variables, prototype functions, then write code
D) Write the main() function, then determine which classes are needed
E) None of these
A) Identify objects, then define objects' attributes, behaviors, and relationships
B) Define data members and member functions, then assign a class name
C) Declare private and public variables, prototype functions, then write code
D) Write the main() function, then determine which classes are needed
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
28
More than one destructor function may be defined for a class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
29
You must declare all data members of a class before you declare member functions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
30
What is the output of the following program? #include
Using namespace std;
Class TestClass
{
Public:
TestClass(int x)
{ cout << x << endl; }
TestClass()
{ cout << "Hello!" << endl; }
};
Int main()
{
TestClass test(77);
Return 0;
}
A) The program runs, but with no output.
B) 77
C) Hello!
D) The program will not compile.
Using namespace std;
Class TestClass
{
Public:
TestClass(int x)
{ cout << x << endl; }
TestClass()
{ cout << "Hello!" << endl; }
};
Int main()
{
TestClass test(77);
Return 0;
}
A) The program runs, but with no output.
B) 77
C) Hello!
D) The program will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
31
Object-oriented programming is centered around the object, which encapsulate together both the data and the functions that operate on the data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
32
Whereas object-oriented programming centers around the object, procedural programming centers around functions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
33
Class objects can be defined prior to the class declaration.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
34
If a local variable and a global variable have the same name within the same program, the _______ resolution operator must be used.
A) variable
B) ambiguity
C) scope
D) global
E) None of these
A) variable
B) ambiguity
C) scope
D) global
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
35
The constructor function may not accept arguments.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
36
Assume that myCar is an instance of the Car class, and that the Car class has a member function named accelerate. Which of the following is a valid call to the accelerate member function?
A) Car->accelerate();
B) myCar::accelerate();
C) myCar.accelerate();
D) myCar:accelerate();
A) Car->accelerate();
B) myCar::accelerate();
C) myCar.accelerate();
D) myCar:accelerate();
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
37
When a member function is defined outside of the class declaration, the function name must be qualified with the:
A) class name, followed by a semicolon
B) class name, followed by the scope resolution operator
C) name of the first object
D) private access specifier
E) None of these
A) class name, followed by a semicolon
B) class name, followed by the scope resolution operator
C) name of the first object
D) private access specifier
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
38
A class may have this many default constructor(s).
A) only one
B) more than one
C) a maximum of two
D) any number of
E) None of these
A) only one
B) more than one
C) a maximum of two
D) any number of
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
39
Objects in an array are accessed with ________, just like any other data type in an array.
A) subscripts
B) parentheses
C) #include statements
D) output format manipulators
E) None of these
A) subscripts
B) parentheses
C) #include statements
D) output format manipulators
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
40
A destructor function can have zero to many parameters.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
41
A private member function is useful for tasks that are internal to the class, but is not directly called by statements outside the class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
42
One purpose that destructor functions are often used for is to free memory that was allocated by the object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
43
You must use the private access specification for all data members of a class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
44
If you do not declare a destructor function, the compiler will furnish one automatically.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
45
When an object is defined without an argument list for its constructor, the compiler automatically calls the object's default constructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
46
One purpose that constructor functions are often used for is to allocate memory that will be needed by the object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck