هـ1435- 1434 الخامس: المستوى وائل خضر/د االمتحان الثاني لنصف الترم Data Structure CSI312 )مادة ( تراكيب البيانات جامعة المجمعة كلية العلوم قسم علوم الحاسب والمعلومات :الرقم الجامعي :أسم الطالب Question(1): Choice the correct answer? 1- Which of the following statements is correct about the constructors and destructors? A. Destructors can take arguments but constructors cannot. B. Constructors can take arguments but destructors cannot. C. Destructors can be overloaded but constructors cannot be overloaded. D. Constructors and destructors can both return a value. 2- Which of the following access specifies is used in a class definition by default? A. Protected C. Private B. Public D. Friend 3. Which of the following keywords is used to control access to a class member? A. Private C. Protected 4- The output of this program is ---------------- B. D. Static Local #include<iostream> class ThreeData { int x, y, z; public: ThreeData(int xx, int yy, int zz) { x = xx++; y = ++yy; z = zz++; } void Show() { cout<< "" << x++ << " " << y++ << " " << z++; } }; int main() { ThreeData objData(1, 2, 3); objData.Show(); return 0; } A. The program will print the output 1 2 3. B. The program will print the output 2 3 4 . C. The program will print the output 1 3 3. 5. To Release a block of data from the memory you must use keyword --------------. 1 Question(2) Define a class BOOK with the following specifications: Private members of the class BOOK are BOOK NO : integer type BOOKTITLE : 20 characters (string) PRICE : float (price per copy) TOTAL_COST( ) : A function to calculate the total cost for N number of copies where N is passed to the function as argument . Public members of the class BOOK are INPUT( ) PURCHASE( ) TOTAL_COST( ) function to read BOOK_NO. BOOKTITLE, PRICE function to ask the user to input the number of copies to be purchased. It invokes and prints the total cost to be paid by the user. Answer: 2 Question(3) class Arrays { private: int* arrayList; // pointer to array of a user defined size int sizeOfArray; // size of the array float avg // average of array public: Arrays (int num); // constructor ~ Arrays ( ); // destructor void setValues( ); // retrieves values from user and sets them to the array void Average( ); // to compute the average of data input void Display( ); // prints out all values in all elements }; Answer: 3 Final Lab Exam in Data Structure : Name: -------------------------------------------------- ID: --------------------- Write a program that contain the following? Define a dynamic integer linked list ? Write a function to insert an integer element into Linked list? Answer: 4