Você está na página 1de 9

CS2203 - Object Oriented Programming Anna University Questions(Unit wise) UNIT-I PART-A 1.

What are the main characteristics of OOP language? 2. What are the valid types of data that the main( ) can return in C/C++ la nguage? 3. Name the mechanism that binds together code and the data it manipulates. 4. What is the application of the scope resolution operator: in C++? 5. What are the two parts of a class specification? 6. intL=5; main ( ) {int i = 6; c o u t < < : : i ; } 7. What is meant access specifier? 8. What is the default access mode for class members? 9. What is object oriented paradigm? 10. Which feature of object oriented programming provides (a)Data hiding (b) Reusability 11. List any two drawbacks of procedure oriented program. 12. What is a class? What is an object? Give an example for each. 13. Define Encapsulation. 14. What is an expression? Give example. 15. State the meaning of the public access specifier. 16. Can the precedence of an operator be altered? 17. What is the use of scope resolution operator :: in c++? 18. What is friend function? 19. What is an abstract base class? Give an example. 20. What is meant by data hiding? 21. Name atleast two OOPS languages other than C++ 22. Why is OOP methodology considered to be the better approach for real lif e problems? 23. What are the use of pointers in C++? 24. What are the three kinds of class members? 25. What is meant by member access modifiers? 26. What is a friend function? What are its advantages and limitations? 27. Name 2 properties of static data member. 28. What are the various access specifiers? 29. How is data hiding achieved in C++? 30. Give some characteristics of procedure-oriented language. 31. What is dynamic binding or late binding? 32. What is a scope resolution operator? 33. What are free store operators (or) Memory management operators? 34. What do you mean by enumerated datatype? 35. What do you mean by dynamic initialization of variables? 36. What are the advantages of default arguments? 37. What are reference variable? 38. What is member-dereferencing operator? 39. What is function prototype? 40. Define pointers to member 41. Define const member, local classes, Nested Classes,implicit conversion 42. Explain basic to class type conversion with an example and vice versa. 43. Explain one class to another class conversion with an example. PART - B 1. Describe the advantages of OOP (or) List out any five merits of object o riented methodlogy(8) 2. Explain the special features of object oriented programming. (16) 3. What are the differences between pointers to constants and constant poin ters? (8)

4. Describe the applications of OOP technology. (8) 5. Explain object-oriented paradigm with all its essential elements.(12) 6. Justify the needs for object-oriented paradigm.(10) 7. What are the different data types supported by C++?(3) 8. What are the differences between reference variables and normal variable s(3) 9. State the merits and demerits of Object Oriented Methodology(4) 10. Explain the following concepts of object oriented programming in detail with example a. Data abstraction(4) b. Inheritance(4) c. Polymorphism(4) d. Objects(4) 11. Write a program for manipulating coordinates in polar coordinate system. Represent points as objects. The class polar must include data members such as radius and theta and member functions such as add(), sub(), angle() etc.(10) 12. Write a C++ program to extracts the elements placed in the odd position of the array.(8) 13. Write a C++ program to print the sum of all squares between 1 and N wher e N is a Number accepted from the keyboard(ie., 1+4++N*N)(12) 14. Give the access rules for accessing static members.(4) 15. Write a program to read a matrix of size m x n from the keyboard and dis play the same on the screen. Make row parameter as a default argument.(8) 16. What are 1) static 2) constant members? Give examples to support your ex planation. 17. What is inline function? Explain the situations where inline expansion m ay not work? 18. Explain the following concepts of object oriented programming in detail with an example. (16): (i) Data abstraction (ii) Inheritance (iii) Polymorphism and (iv) Objects 19. What is the main draw-back of structured programming? How OOP address th is issue? 20. What are the elements of OOPS? How do these make OOPS approach best sui ted to address real world problems? (8) 21. Using the concept of function overloading, write a program in C++ to fin d the maximum of three integers and three float numbers. (10) 22. Write a C++ program to find the area of the square, rectangle, circle using function overloading. (10) 23. Give two parts of method declaration. How is a static method invoked? Wh en will the method complete execution and return to the caller? How wiil methods return more than one result? 24. What do you understand by static member and static function? How to decl are them? (10) 25. Create a class that keeps track of its number of instances 26. List the special characteristics of friend function. (6) 27. What are friend functions? Give an example to highlight its need? What i s its limitation? 28. Create two classes DM and DB to store the value of distances. DM stores the distances in meters and centimeters and DB in feet and inches. Write a progr am that can read values for the class objects and add one object of DM with anot her object of DB. Use a friend function to carry out the addition operation. The object that stores the result may be a DM or DB object depending on the units i n which the results are required. The display should be in ft-inches or mt-cm de pending on the object of display.(16) UNIT-II PART-A 1. What are the difference between default and parameterized constructors? 2. How does constructors differ from normal functions?

3. What is default constructors? When it is used? 4. What is an operator function? Describe the syntax of an operator functio n. 5. How do objects interact? 6. What is the difference between a constructor and destructor? 7. Why are destructors used? Write the syntax of destructor. 8. What are the characteristics of constructor functions? 9. Write any four special properties of constructor. 10. How the objects are initialized dynamically? 11. What is polymorphism? What are its types? 12. What is function overloading? Give an example. 13. What is operator overloading? List out the operators that cannot be over loaded. 14. What is the purpose of using operator function? Write its syntax. 15. Write at least four rules for Operator overloading. 16. What are the operators of C++ that cannot be overloaded? 17. What are the operators of C++ that cannot be overloaded only by friend f unctions? 18. How will you overload Unary & Binary operator using member functions? 19. How will you overload Unary and Binary operator using Friend functions? 20. How an overloaded operator can be invoked using member and friend functi ons? 21. List out the operators that cannot be overloaded using Friend function. 22. List any four operators that cannot be overloaded. 23. What is meant by casting operator and write the general form of overload ed casting operator. PART - B 1. Explain copy constructor with suitable C++ coding. 2. List out the rules for overloading operators. 3. Write a program to overload = operator. Assign values of data members of one object to another object of the same type. 4. Write a program which reads a complex number and copy that into another. Use copy constructor for writing program 5. What is meant by overloading? How is operator overloading works? (4) 6. Write a program to add 2 complex numbers using operator overloading. What are the operators that cannot be overloaded in C++? 7. Which are the C++ operators which cannot be overloaded? 8. What are the rules associated in defining constructors and destructors.(6) 9. State the rules to be followed while overloading an operator. Write a program to illustrate overloading.(8) 10. Write a program to overload unary operator ++ for incrementing distance. Ass ume that the distance class has feet and inches as data members.(12) 11. What is an operator overloading? How many arguments are required in the defi nition of an overloaded binary operator?(6) 12. Write a program which initialized 10 and 200 to member data and then calcula te the sum of these. (6) 13. Write a program which reads a complex number copy that into another. Use cop y constructor for writing program. 14. Explain the different types of constructors with suitable examples. (16) 15. Define a C++ class Matrix to describe a matrix. Equip the class with functio ns for addition and multiplication. Overload operators suitably for input and ou tput of the matrix. (16)

UNIT-III PART-A 1. What are the types of exceptions? C++ provides what type of exceptions.

2. Is template a basic feature of C++? Justify your answer. 3. Give the syntax of declaring a function template 4. What is the advantage of template in C++? 5. Write a program to implement stack operations using class template. (8) 6. Write a function which swaps two numbers. Use function template' Write t he corresponding main program. 7. What is the main purpose of a template in C++? Give an example. 8. Give any two examples of exceptions. 9. Write a function template to swap two variables. 10. What is an exception? Give any four examples of exception. 11. Why it is not possible to refer an exception declared within try block o utside try block? 12. How is an exception handled in C++? 13. What are the keywords used in C++ for exception handling? Describe their usage with suitable example.(8) 14. What is Explicit Specialization 15. Distinguish the terms class template and template class 16. What is instantiation? 17. What is a template? 18. What is the need of templates? 19. What is uncaught_expection() and why do we need it? 20. What is rethrow()? What is its use? 21. Give the general syntax for throw. PART - B 1. Explain multiple catch statement with the help of suitable C++ coding. 2. Discuss the need for exception with try, catch and throw keywords. (10) 3. Write a program which generates a template class by which one can perfor m integer type data addition and float type data addition also. (10) 4. What is the need for and advantages of templates? What is the differenc e between function template and class template? (6) 5. What is exception handing? Explain. (4) 6. List the advantages of exception handling mechanisms. (4) 7. For handling exception what type of constructs are available in C++. (8) 8. Write a program that generates a template class by which one can perform integer type data addition and float type data addition also. (10) 9. How is unusual error conditions avoider using C++? 10. For handling exceptions what type of functions are available in C++. Exp lain functions along with their syntax and Program. 11. Design template classes such that they support the following statements: a. Rupee<float>r1,r2; Dollar <float>d1,d2; D1=r2 //converts rupee into dollar. (8) 12. Explain the exception handling model of C++ with various constructs supp orted by it. Write a program which transfers the control to user defined termina te function when raised exception is caught.(8) 13. Explain how exception handling is achieved in C++? Give 5 different cons tructs and explain the working of them. 14. Explain the use of try, catch and throw keywords in handling exceptions in a program. Indicate how the control flows in case of occurrence and non-occur rence of exceptions. Write a program to implement a stack with appropriate excep tion handling 15. Give the syntax of function template. Write template function for bubble sort. Write a test program to illustrate its use. 16. Write a function template for finding the minimum value contained in an array. (8) 17. Explain the overloading of template function with suitable example 18. Write a C++ program for the following: (1) A function to read two double type numbers from keyboard. (2) A function to calculate the division of these two numbers.

(3) A try block to throw an exception when a wrong type of data is keyed in. (4) A try block to detect and throw an exception if the condition ''divide-by-ze ro'' occurs. (5) Appropriate catch block to handle the exceptions thrown. (12) 19. Explain how exceptions are handled in C++. Give examples support your a nswer.(8) UNIT-IV PART-A 1. Name the various types of multiple inheritance 2. Give atleast two examples of compile time polyrnorphism. 3. Why is the derived class constructor called before the base class constr uctor? 4. What effect does inheritance have on the working of constructors and des tructors? 5. What is abstract base class? Can it be used to create objects? 6. What are the types of inheritance? 7. List any four advantages of inheritance? 8. What is meant by Abstract base class? 9. Write short notes on virtual base class. 10. List out the rules of Virtual Functions 11. When do we make a class virtual? 12. Difference between access specifier and modifier 13. Define RTTI 14. What is virtual table? 15. Why do we need RTTI? Suggest some cases where we need to use RTTI. 16. What are polymorphic object. 17. List the features of Dynamic_cast 18. What are all issues of RTTI 19. Distinguish between early binding and late binding. 20. Define cross casting. 21. Define down casting PART - B 1. Explain hybrid inheritance with suitable C++ coding. 2. Define polymorphism. Explain the different types of polymorphism. 3. Write a C++ program using inheritance to implement the following. A newspaper agent pays two variant rates for the delivery of newspapers. A deliv ery boy can earn RS. 2 on a morning delivery but only Rs. 1.50 on an evening del ivery. Boys are salaried either for a morning delivery or for an evening paper r ound but not for both. Read(Input) the code for round (0 for morning and 1 for e vening) and the number of total paper rounds in one week done by a boy and compu te his earning and display it. 4. write a program which reads the bio-data and records of two sessional an d then print final result. Make separate class for bio-data, sessional 1, sessio nal2 and final result. sessional 1 and sessional 2 classes are derived from biodata class. Find result in defined from sessional 1 and sessional 2 classes' (. 12) 5. Explain the concepts identify in the program' (4) 6. What are the special features of virtual functions? 7. Give the rules for writing virtual functions. (6) 8. What are virtual functions? Give an example to highlight its need? 9. Write a C++ program to illustrate the use of virtual function. (10) 10. What are the various types of inheritance? Discuss any three types of in heritance. 11. Discuss function overloading and operator overloading with illustrations . 12. Discuss hierarchical inheritance. 1. Write a c++ program that will give the conditions of environments requir

ed, food habits and unique characteristics of pet animals fish and dog. Define a base class called pet that describe any common household pet; two derived class es called fish and dog with item specific to that type of animals. Write pure vi rtual functions in the base class for operations that are common to both types o f animals. Write a program to test the usage of that classes. 2. What are the different form of inheritance supported by C++? Explain the m with an example.(10) 3. Create a C++ program to model the following inheritance hierarchy.

4. Create a class to model entries in a telephone directory (name, address, phoneno). Define suitable classes and inheritance hierarchy. Write a program to test these classes. 5. Consider the following class declarations in C++. class C { Protected:int x; public:void f(){} ]; class C1:public C{ protected:int x1; public:void h(C*obj){}; }; class C2:public C1{ public:int x2; }; class C3:public C{ public:f(){..} }; (i) Assume that main contains the following declarations. C1 obj1; For each of the following expressions, say whether it is allowed in the code of main or not. obj1.x, obj1.f(), obj1.x1, obj1.x2 (ii) Assume that the body of C1::h contains the following declarations. C2 *obj2; C3 *obj3; For each of the following expressions, say whether it is allowed in the body of C1::h or not. (iii) Assume that the body of C1::h contains the following statement Obj->f(); Assume that we call C1::h with a parameter(pointing to an object) of class C3. W hat is the method f executed, C::f() or C3::f()? And what would be the method ex ecuted if f were declared virtual in C? 6. Define classes Polygon, Rectangle and Triangle to represent figures poly gon, rectangle and triangle respectively. Equip each classes with a function are a to calculate the area of appropriate figure. Write a main program using these classes to illustrate how pointer to the super class objects can be used to acce ss objects of subclasses and to test the function area defined in these classes.

7. Implement the following inheritance hierarchy in C++. Give atleast 2 fun ctions in each class. Describe any 4 features of Object Oriented programming use d in the program.

13. Differentiate abstract classes and interfaces 14. Write a program to derive class final from class marks and class biodata . the scheme is provided for reference: Class biodata with a minimum of members : Name, Semester, Age, Roll number Class marks with : Subject name and mark Phone No. is the data member in final as in structure of final Class final Private number Ph. No. Public number getbio() show bio ( ) show m ( ) getph() show ph ( )

inherited from class bio

inherited from class marks

UNIT-V PART-A 1. What are input and output streams? 2. What are the classes in iostream.h header files? 3. What is an I/O stream? 4. What are the functions supported by file stream classes for performing I /O operations? 5. Name the features included in C++ for formatting the output. 6. Difference between get (), put (). 7. Write a c++ code to swap two strings. 8. How to open and close a file? 9. Write some file opening modes.

10. What is a file pointer? 11. Write a program to read words and print in reverse order. Illustrate use of new keyword to dynamically allocate space for each of the strings that are r ead in.(16) 12. What is file mode? List any four file modes. 13. What is command-line argument? 14. What is an error and error handling functions? 15. How will you create manipulators? 16. Define STL. 17. Define Object Serialization. 18. What is STD Namespace? 19. List out some ANSI string objects. 20. Write the syntax and use of getline () and write () functions 21. List out some I/O streams supported by C++. 22. What stream class is required to create an output stream? 23. What is the output of the following? n=37 cout.setf(ios::left); cout<<setfill(0)<<setw(8)<<n; 24. What is the difference between the following statements. a. cin>>ch; b. ch=cin.get()

PART - B 1. Write a C++ program to read from 2 files simultaneously. 2. Give the hierarchy of console stream classes. 3. Explain about Standard template library 4. Write a program to write and read data in a file using object I/O funct ions write( ) and read ( ). Declare class with data members name [2]. int bill_n o, int amount _debited and int received _ amount and in balance. Add 10 records and display the list of persons with balances. The user should have a facility t o modify the existing records.(16) 5. Explain a. Object seralization b. std namespaces 6. Describe the various file modes and its syntax. (6) 7. Explain the use of any six manipulators with example. (6) 8. Discuss in detail the unformatted I/O operations. (10) 9. Explain the concept of streams in C++ and give the hierarchy of differen t types of stream. 10. Explain the stream classes for file operations with suitable diagram. (4) 11. Explain the 4 functions seekg, seekp, tellg, tellp used for setting poin ters during the file operations and show how they are derived from f stream clas ses.(6) 12. Write a program to append to the content of the file(10). 13. What are file modes? Describe various file mode options available in C++ . 14. Write a program to write the text in a file. Display the contents of the file in the reverse order.(8) 15. Write about Random Access to a file? 16. Write an interactive, menu-driven C++ program that will access the database file containing the list of telephone numbers and their corresponding customer name, and implement the following tasks : (1) Determine the telephone number of the specified person. (2) Determine the name if the telephone number is known.

(3) Update the telephone number, whenever, there is a change.(12)

Você também pode gostar