Вы находитесь на странице: 1из 4

R403

Register No: Name : RAJAGIRI SCHOOL OF ENGINEERING AND TECHNOLOGY !TECH DEGREE FIRST INTERNAL E"A#INATION$ #ARCH %00& Fo'rt( Semester O)*e+t Orie,te- .rogrammi,g

Time: 2 hours

Maximum Marks: 50 Answer all questions. All questions carry equal marks

.art A
(Fill in the blanks)

1. A function call resolved at run time is referred to as ________ binding. 2. When two objects of a class are created, _______ copies of data members and _____ copies of member functions are stored in the memory. 3. all by reference is achieved by applying ___________ operator to the formal parameters. !. "he default access mode for a class member is ____________ #. "he process by which objects of one class ac$uire the attributes of objects of another class is %nown as_________________ &1 ' # ( #) .art
(Multiple Choice questions)

*. What would be the output of the following program+ int main&) , int -, y(1.,/(1.0 - ( &y ( ( /)0 cout11-0 return .0 2 A. 3. . 4. . 1 1. 5rror

6. onsider the following class definition. lass person , 20 lass student7 protected person

, 20 What happens when we try to compile this class+ A. 3. . 4. ode will not compile because class body of a person is not defined. ode will not compile because class body of a student is not defined. ode will not compile because class person is not public inherited. ode will compile successfully.

8. When a continue statement is e-ecuted within a loop, the control goes to A. "he ne-t statement in the loop 3. "he top of the loop . "he statement immediately after the loop 4. "he beginning of the program 5. "he end of the program 9. Which of the following will produce a value of 22 if - ( 22.9+ A. ceil&-) 3. log&-) . abs&-) 4. floor&-) 1.. What will be the result of the e-pression 13 : 2#+ A. 38 3. 2# . 9 4. 12 &1 ' # ( #) .art C
(True or False)

11. ;n case constructors are not specified in a derived class, the derived class will use the constructors of the base class for constructing the objects. 12. A member variable defined as static is visible to all classes in the program. 13. A variable declared above all the functions can be accessed only by the main function. 1!. ;n <<, only =int> type variables can be used as loop control variables in a =for> loop. 1#. ;n <<, declarations can appear almost any where in the body of a function. &1 ' # ( #)

.art D
(Answer all questions)

1*. a) ?ewrite the following code using a while loop structure. int i0 for &i(.0 -1#0 <<i) , @@ << statements 2 b) When do we use the following statement+ for&00) 16. What is the output of the following code segment+ int n ( .0 int i ( 10 do , cout11i0 i<<0 2 while &i 1(n) 18. What is wrong with the following code+ class A3 , private 7 const int m (1.0 public7 @@ code here 20 19. reate a class called bo- whose constructor function is passed three double values, each of which represents the length of one side of a bo-. Aave the bo- class compute the volume of the bo- and store the result in a double variable. ;nclude a member function called vol&) that displays the volume of each object. 2.. reate a class called employee that contains a name &an array of char) and an employee number &type long). ;nclude a member function called getdata&) to get data from the user for insertion into the object , and another function called putdata&) to display the data. Write a main program to e-ercise this class. ;t should create an array employee, and then invite the user to input data for up to 1.. employees. Binally it should print out the data for all the employees. &! ' # ( 2.)

21. ;magine a situation in which two classes, called pr1 and pr2, shown here, share one printer. Burther, imagine that other parts of your program need to %now when the printer is in use by an object of either of these two classes. reate a function called inuse&) that returns true when the printer is being used by either and false otherwise. Ca%e this function a friend of both pr1 and pr2. class pr1 , int printing0 @@D.. public7 pr1&) ,printing (.02 void set_print&int status),printing ( status02 @@DD 20 class pr2 , int printing0 @@D.. public7 pr2&) ,printing (.02 void set_print&int status),printing ( status02 @@DD 20 &1. ' 1 ( 1. )

Вам также может понравиться