Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
448 views

NR 220504 Object Oriented Programming

The document contains the question paper for the II B.Tech. II Semester Supplementary Examinations in Object Oriented Programming held in November 2003. The paper contains 8 questions covering topics such as object oriented concepts, C/C++ programming, classes and objects, inheritance, templates, exceptions etc. Students had to answer any 5 questions out of the 8 questions given.

Uploaded by

Srinivasa Rao G
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
448 views

NR 220504 Object Oriented Programming

The document contains the question paper for the II B.Tech. II Semester Supplementary Examinations in Object Oriented Programming held in November 2003. The paper contains 8 questions covering topics such as object oriented concepts, C/C++ programming, classes and objects, inheritance, templates, exceptions etc. Students had to answer any 5 questions out of the 8 questions given.

Uploaded by

Srinivasa Rao G
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

Set No.

Code No. 220504 1


II B.Tech. II Semester Supplementary Examinations, November-2003

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.

2.a) What is C preprocessor? Explain various preprocessor directives?


b) Write a C program that reverses a string.

3.a) Illustrate dynamic allocation with new operator Vs with malloc operator
b) Write a C program to find the prime numbers in the range 1..100.
c) 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

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.
b) Explain about the ambiguity in inheritance with any specific program example.

Contd…2.
Code No.220504 -2- Set No.1

6. Write an example program to illustrate


i) Virtual member function
ii) Pure virtual member function

7.a) Why do subscript operators usually come in pairs? Explain.


b) 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.

-x-
Set No.

Code No. 220504 2


II B.Tech. II Semester Supplementary Examinations, November-2003

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.

2.a) Write a C program to transpose a matrix.


b) What is conditional inclusion of code during preprocessing?
c) Illustrate four functions in the <ctype.h> header file.

3.a) Write short notes on the scope of variables.


b) Write a C program to test whether a number is prime or not
c) 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.
b) 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.

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

6. 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);
b) Write a function to reverse a string in place (i.e without duplicating all the
characters).
c) Why is it necessary to include the file iostream in all our programs?

8.a) Identify which, if any, of the following template instantiations are valid. Explain
why?
template<int *ptr> class Ptr {…………………};
template< class Type, int size> class Fixed_Array {………};
template<int hi, int wid> 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;
b) Write a program that demonstrates how certain exception types are not allowed to
be thrown?
-x-
Set No.

Code No. 220504 3


II B.Tech. II Semester Supplementary Examinations, November-2003

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.

2.a) Illustrate any four functions in the <math.h> header file.


b) 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.
b) Compare recursion with iteration.
c) Write a C program that reads a character array and gives frequency count
of each character.

4. 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.

b) Write a program to explain how to define, declare and invoke the destructor
members functions under multiple inheritance.
c) 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.

6. Illustrate the following with an example program for each.


i) Virtual member function accessed with pointer
ii) Virtual functions and the person class

Contd…2.
Code No.220504 -2- Set No.3

7.a) 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?
b) Why is the default constructor for the ios class declared private?
c) Why is the ios class made to be a virtual base class for the istream and ostream
classes?

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;
b) Name the two template compilation models supported in C++. Explain how
programs with function template definitions are organized under each
compilation model.

-x-
Set No.

Code No. 220504 4


II B.Tech. II Semester Supplementary Examinations, November-2003

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.

2.a) Write a C function which converts a string of digits into its numeric
equivalent.
b) Illustrate any four functions in the <stdlib.h> header file.

3.a) Contrast prefix usage of ++ operator with postfix usage of it. Similarly, contrast
the usage of -- operator. Illustrate.
b) Enumerate the bitwise operators in C with their use.

4. 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.
b) 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.

Use member functions to initialize the class members.

Contd…2.
Code No.220504 -2- Set No.4

6.a) Write a program for checking the type of a class with dynamic cast.
b) Write a program for changing pointer types with dynamic-cast.

7.a) How do the I/O facilities in C++ differ from that in C?


b) Discuss the various forms of get( ) function supported by the input stream. How
are they used?

8.a) Write a program to demonstrate the concept of rethrowing an exception.


b) Identify which of the following function template definitions are illegal. Why?

i) template<class A, B>+
void fun(A, B) {………………..};
ii) template<class A>
void fun(A,A) {…………..};
i) template<class T, typename R>
T fun(T, R) {……………….};
ii) template<class A>
A fun(int *A) {……………….};

-x-

You might also like