Sunteți pe pagina 1din 9

Object Oriented Programming with C++

Chap 01 1. Explain call by value and call by reference with example. 2. What is inline function? Write a program to implement inline function. 3. Differentiate between procedure oriented programming and object oriented programming. 4. Write a program for default arguments to function. 5. What is function overloading? Write a program function overloading. 6. What is recursive function? Write a program for recursive function. Chap 02 1. Write a program to implement array of objects. 2. What is use of friend function? Explain with example. 3. Define a class to represent a Bank account. Include the following members: Data members: 1. Name of depositor 2. Account number 3. Type of account 4. Balance amount in the account Member function: 1. To assign initial values 2. To deposit an amount 3. To withdraw an amount after checking the balance 4. To display name and balance Write a main program to test the program. 4. What is constructor? Write a program for constructor overloading. 5. Write a program to add two complex numbers using operator overloading technique. 6. Write a program for static data member and static member function. 7. Write rules for operator overloading. 8. What is constructor? Write a program to overload different types of constructors. 9. How to return object from function? Explain with example.

10. What is a conversion function? How is it created? Explain its syntax. 11. How is dynamic initialization of objects achieved? 12. Explain new and delete operator with example. 13. What are the different access specifiers in c++? 14. Write a note on scope resolution operator. 15. Create a class FLOAT that contains one float data member. Overload all the four arithmetic operators so that they operate on the objects of FLOAT. 16. Define a class String. Use overload == operator to compare two strings. 17. Define two classes Polar and Rectangle to represent points in the polar and rectangle systems. Use conversion routine to convert from one system to other. 18. Create two classes DM and DB which stores the value of distance. DM store distance in meter and centimeter. DB store distance in feet and inches. Write a program that can read values of class objects and add one object of DM with object of DB. Use a friend function to carry out the addition operation. The object that stores the result may be DM or DB depends on the unit in which results are required. Chapt 03 1. Assume that a bank maintains two kinds of accounts for customers, one called as savings account and the other as current account. The savings account provides compund interest and withdrawal facilities but no cheque book facility. the current account provides cheque book facility but no interest. Current account holders should also maintain a minimum balance and if the balance falls below this level, a service charge is imposed. Create a class account that stores customer name, account number and type of account. from this drive the classes cur_acct and sav_acct to make them more specific to their requirements. Include necessary member functions in order to achieve the following tasks: a) b) c) d) e) Accept deposit from a customer and update the balance. Display the Balance. Compute and deposit interest. Permit withdrawal and update the balance. Check for the minimum balance, impose penalty, necessary, and update the balance.

Do not use any constructors. Use member functions to initialize the class members.

2. An educational institution wishes to maintain a database of its employees. the database is divided into a number of classes whose hierarchical relationships are shown in Fig.1 the figure also shows the minimum information required for each class. Specify all the class. Specify all the classes and define function to create the database and retrieve individual information as and when required.

staff code Name

Teacher

Officer

Subject Publication

Typist

Grade

Speed
Regular

Casual

Figure 1.
Daily 3. Consider a class network of Fig 2 the class master derives information from both account and admin classes which in turn derive information from the class person. Define all the four classes wages and write a program to create, update and display the information contained in Master Objects.

person code Name

Account

Admin

Pay experience Person

Name code experience Pay

Figure 2.

Chap . 4 and 5 1. Create a base class called shape. use this class to store two double type values that could be used to compute the area of figures. Derive two specific classes called triangle and rectangle from the base shape. add to the base class, a member function get_data() to initialize base class data members and another member function display_area() in compute and display he area of figures. Make display_area() as a virtual function and redefine this function in the derived classes to suit their requirements. Using these three classes, design a program that will accept dimensions of a triangle or a rectangle interactively, and display the area. Remember the two values given as input will be treated as lengths of two sides in the case of rectangles, and as base and height in the case of triangles, and used as follows: Area of rectangle = x * y Area of triangle = *x * Y 2. Extend the above program to display the area of circles. This requires addition of a new derived class circle that computes the area of a circle. Remember, for a circle we need only one value, its radius, but the get_data () function in the base class requires two values to be passed. (hint: make the second argument of get_data() function as a default one with zero values.) 3. Run the above program with the following modifications: a) Remove the definition of display_area() from one of the derived classes.. b) In addition to the above change, declare the display_area() as virtual in the base class shape. Comment on the output in each case. 4. What is virtual function? What are the rules for virtual functions? 5. What is virtual base class? Consider the result processing system as shown in figure given below:

Student

Test

Sports

Result 6. Write a program to implement student virtual base class.

7. Write a program to implement multiple inheritance. 8. What is inheritance? Explain different types of inheritance. 9. How compile-time and run-time polymorphism is achieved? Explain with example. 10. What does this pointer point to? What are the applications of this pointer? 11. Explain virtual function and pure virtual function with example. 12. Write a program for dynamic initialization of objects. 13. What is inheritance? Write a program for single inheritance. Chap-06 1. Explain stream class hierarchy. 2. Explain different file modes. 3. Explain template classes for stacks. 4. Write a program for reading and writing strings from file. 5. Explain error handling during file operations. 6. Write a program to read a text file and copy it to the output file character by character. 7. Explain different file pointers. 8. Explain manipulators in c++. 9. Write a program with the following: a) A function to read two integer type numbers from keyboard. b) A function to calculate the division of these two numbers. c) A try block to detect and throw an exception if the condition divide by zero occurs. d) Appropriate catch block to handle the exception thrown. Two marks questions: 1. What is Object? 2. What is class? 3. What do you mean by data abstraction and encapsulation? 4. What is dynamic binding?

5. What is message passing? 6. What are the benefits of OOP? 7. Explain output operator cout in c++. 8. Why to include header files? 9. What do you mean by reference variable. 10. What is destructor? 11. How to define operator function? 12. Why it is necessary to overload an operator? 13. What do you mean by access specifiers? 14. What is object oriented programming? 15. Distinguish between polymorphism and inheritance. 16. What is data hiding? 17. What is default constructor? 18. Differentiate between structure and class. 19. What is type casting? 20. What is abstract class? 21. What does inheritance mean in c++? 22. When do you use the protected visibility specifier to a class member? 23. What does polymorphism mean in c++? 24. What are the applications of this pointer? 25. When do you need virtual functions? 26. What is manipulator? List the manipulators in c++. 27. What role does the iomanip file play? 28. How to detect end of a file? 29. Identify the error in the following program. #include<iostream.h>

Class Room { int width, height; void setValue(int w, int h) { width=w; height=h; } }; void main() { Room objRoom; objRoom.width=12; } 30. Identify the error in the following program. #include<iostream.h> void main() { int i=0; i=i+1; cout<<i<< ; /*comment\*//i=i+1; cout<<I; } 31. Identify the error in the following program. #include<iostream.h>

int fun() { return 1; } float fun() { return 10.23; } void main() { cout<<(int)fun()<< ; cout<<(float)fun()<< ; } 32. Identify the error in the following program. #include<iostream.h> class Room { int length; int width; public: Room() { length =0; width =0; } Room(int value=8)

{ length=width=8; } void display() { cout<<length<< <<width; } }; void main() { Room objRoom1; objRoom1.display(); } 33. Distinguish between the following two statements: time T2(T1); time T2=T1; T1 and T2 are objects of time class. 34. Describe the importance of destructors.

35. What is the output from each code segment below? int x = 1, y = 0; if (x > 0 && y < 0) { x = y = 23; } cout << x << " " << y << endl;

S-ar putea să vă placă și