Set No.
1
Code No. 220504 II B.Tech. II Semester Supplementary Examinations, November-2003
.in
OBJECT ORIENTED PROGRAMMING (Common to Computer Science and Engineering, Computer Science and Information Technology, Computer Science and Systems Engineering and Electronics and Computer Engineering) Time: 3 hours Max. Marks:80 Answer any Five questions All questions carry equal marks --1. Explain about the concepts of object-oriented programming. What is C preprocessor? Explain various preprocessor directives? Write a C program that reverses a string.
3.a) b) c)
Illustrate dynamic allocation with new operator Vs with malloc operator Write a C program to find the prime numbers in the range 1..100. Explain the significance and usage of the return statement illustrately.
4.
Implement a circle class. Each object of this class will represent a circle, storing its radius and the x and y coordinates of its center as float. Include a default constructor, access functions (to accept and to print), an area( ) function, and a circumference () function.
5.a)
Develop an object oriented programming in C++ to prepare the mark sheet of an university examination with the following items read from the keyboard: Name of the student Roll number Subject name Subject code Internal marks External marks
nt
uW
or ld
2.a) b)
Aj
b)
Design a base class consisting of the data members such as name of the student, roll number and subject name. The derived class consists of the data member’s viz., subject code, internal marks and external marks. The program must be able to build a table, list a table, insert a new entry and deleting a new entry. Explain about the ambiguity in inheritance with any specific program example.
Contd…2.
Code No.220504
-2-
Set No.1
Write an example program to illustrate i) Virtual member function ii) Pure virtual member function
7.a) b)
Why do subscript operators usually come in pairs? Explain. What is the difference between the i) get( ) function and the getline( ) function. ii) get( ) function and the read( ) function.
8.a)
Write a class template to represent a generic vector. Include member functions to perform the following tasks: i) to create the vector ii) to modify the value of a given element iii) to multiply by a scalar value iv) to display the vector in the form (10,20,30,……) b) Explain the differences between Templates and Macros.
or ld
.in
6.
Aj
nt
uW
-x-
Set No.
2
Code No. 220504 II B.Tech. II Semester Supplementary Examinations, November-2003
.in
OBJECT ORIENTED PROGRAMMING (Common to Computer Science and Engineering, Computer Science and Information Technology, Computer Science and Systems Engineering and Electronics and Computer Engineering) Time: 3 hours Max. Marks:80 Answer any Five questions All questions carry equal marks --1. Explain about hybrid design methods and justify their use with suitable examples. Write a C program to transpose a matrix. What is conditional inclusion of code during preprocessing? Illustrate four functions in the header file.
3.a) b) c)
Write short notes on the scope of variables. Write a C program to test whether a number is prime or not Contrast static variable in C with static member variable in C++
4.
Implement a square class. Each object of this class will represent a square, storing its side as float. Include a default constructor, access functions (to accept and to print), an area( ) function, and a perimeter( ) function.
5.a)
Explain the order of initialization of different classes constructors in multilevel inheritance with proper example program. Develop an object oriented program in C++ to create a pay roll system of an organization with the following information read from the keyboard: Employee name Employee code Designation Account number Date of joining Basic pay DA,HRA, and CCA Deduction like PPF,LIC etc.
uW
nt
b)
or ld
2.a) b) c)
Aj
Design a base class consisting of employee name, code and designation and another base class consisting of the data member, such as account number and date of joining. The derived class consists of the data member of basic pay plus other earnings and deductions. The program must build a master table, list a table, inset a new entry edit entry and search for a record that is to be printed. Contd…2.
Code No.220504
-2-
Set No.2
Explain function overloading in base and derived classes and illustrate it with a program.
7.a)
How do the following two statements differ in operation? cin >> c; cin.get(c); Write a function to reverse a string in place (i.e without duplicating all the characters). Why is it necessary to include the file iostream in all our programs?
b) c)
Identify which, if any, of the following template instantiations are valid. Explain why? template class Ptr {…………………}; template< class Type, int size> class Fixed_Array {………}; template class Screen {……………..}; i) const int size = 1024; Ptr < &size > bp1; ii) Ptr < 0 > bp2; iii) int arr[10]; Ptr < arr >bp3; iv) const double db = 3.1415; Fixed_Array < double, db > fa1; v) const int hi = 40; const int wi = 80; Screen < hi, wi+32 > sObj; Write a program that demonstrates how certain exception types are not allowed to be thrown? -x-
Aj
nt
b)
uW
or ld
8.a)
.in
6.
Set No.
3
Code No. 220504 II B.Tech. II Semester Supplementary Examinations, November-2003
.in
OBJECT ORIENTED PROGRAMMING (Common to Computer Science and Engineering, Computer Science and Information Technology, Computer Science and Systems Engineering and Electronics and Computer Engineering) Time: 3 hours Max. Marks:80 Answer any Five questions All questions carry equal marks --1. Explain Grady Booch approach for object oriented design with examples. Illustrate any four functions in the header file. Write a C function to convert upper case characters to lower case.
3.a)
What is recursion? Give recursive definitions for GCD of two numbers and for factorial of a number. Compare recursion with iteration. Write a C program that reads a character array and gives frequency count of each character.
b) c)
or ld
2.a) b)
Implement a rectangle class. Each object of this class will represent a rectangle, storing its sides as float. Include a default constructor, access functions (to accept and to print), an area( ) function, and a perimeter( ) function.
5.a)
Write a program to demonstrate how the destructor member function gets fired from the derived class objects to the base class objects through pointers. Write a program to explain how to define, declare and invoke the destructor members functions under multiple inheritance. Explain how public members of a class can be accessed by the following: i) member function of the class ii) non-member functions of the class iii) member functions of the friend class.
b)
nt
c)
uW
4.
Illustrate the following with an example program for each. i) Virtual member function accessed with pointer ii) Virtual functions and the person class
Aj
6.
Contd…2.
Code No.220504
8.a)
Which, if any, of the following throw expressions are errors? Why? For the valid throw expressions, indicate the type of the exception thrown? i) class exceptionType { }; throw exceptionType( ); ii) int excpObj; throw excpObj; iii) enum mathErr {overflow, underflow, zeroDivide }; throw zeroDivide( ); iv) int *pi = excpObj; throw pi; Name the two template compilation models supported in C++. Explain how programs with function template definitions are organized under each compilation model. -x-
Aj
nt
uW
b)
Why is the use of the << and >> operators called “formatted” I/O, and the use of the functions put( ), get( ), read( ), write( ) etc., call “unformatted” I/O? Why is the default constructor for the ios class declared private? Why is the ios class made to be a virtual base class for the istream and ostream classes?
.in
b) c)
Set No.3
or ld
7.a)
-2-
Set No.
4
Code No. 220504 II B.Tech. II Semester Supplementary Examinations, November-2003
b) 3.a) b)
Write a C function which converts a string of digits into its numeric equivalent. Illustrate any four functions in the header file.
or ld
2.a)
.in
OBJECT ORIENTED PROGRAMMING (Common to Computer Science and Engineering, C omputer Science and Information Technology, Computer Science and Systems Engineering and Electronics and Computer Engineering) Time: 3 hours Max. Marks:80 Answer any Five questions All questions carry equal marks --1. Explain in detail about the responsibility-driven design.
Contrast prefix usage of ++ operator with postfix usage of it. Similarly, contrast the usage of -- operator. Illustrate. Enumerate the bitwise operators in C with their use. Implement a sphere class. Each object of this class will represent a sphere with float data members for radius and the three-dimensional point center. Include a default constructor, access functions (to accept and to print), a surface area( ) function, and a volume( ) function.
5.a)
Write a program to show how to define and declare a class which consists of both virtual members and virtual destructors under multiple inheritance. Consider a bank maintains two kinds of accounts for customers, savings account and current account. The savings account provides compound interest and withdrawal facilities but no cheque facility. The current account provides cheque book facility but no interest. Create a class account that stores customer name, account number and type of account. From this, derive 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) Accept deposit from a customer and update the balance. (b) Display the balance. (c) Compute and deposit interest. (d) Permit withdrawal and update the balance.
Aj
nt
b)
uW
4.
Use member functions to initialize the class members.
Contd…2.
Code No.220504
-2-
Set No.4
Write a program for checking the type of a class with dynamic cast. Write a program for changing pointer types with dynamic-cast.
7.a) b)
How do the I/O facilities in C++ differ from that in C? Discuss the various forms of get( ) function supported by the input stream. How are they used?
8.a) b)
Write a program to demonstrate the concept of rethrowing an exception. Identify which of the following function template definitions are illegal. Why?
ii) i) ii)
template+ void fun(A, B) {………………..}; template void fun(A,A) {…………..}; template T fun(T, R) {……………….}; template A fun(int *A) {……………….};
or ld
i)
.in
6.a) b)
Aj
nt
uW
-x-