DR B R Ambedkar National Institute of Technology, Jalandhar CSPC-203, Object Oriented Programming End Semester Examination, Dec 2020
DR B R Ambedkar National Institute of Technology, Jalandhar CSPC-203, Object Oriented Programming End Semester Examination, Dec 2020
DR B R Ambedkar National Institute of Technology, Jalandhar CSPC-203, Object Oriented Programming End Semester Examination, Dec 2020
Note:
1. Attempt all the questions.
2. Write the answers in hard copy (on A4 sheet) using blue/black pen with
your signature on top left and page number on top right corner of each
page of the answer booklet.
3. The time allowed for writing examination is 02 hours. Extra 15 minutes
are allowed for preparing the PDF file of Answer Booklet and submitting
it.
4. Follow the instructions regarding submission of answer booklet as issued
by the examination section.
1
e. Can we use the same name for member function as well
as outside function? If yes then explain how it can be
distinguished?
3. Create a class Chars that could be defined as user-defined
character array type. Include constructors that will enable us to
create an uninitialized char array:
a. Chars s1; // Character array with length 0
b. Initialize an object with a character array constant at the
time of creation like Chars s2(“Well done!”);
c. Include a function that adds two Chars to make a third
Chars.
d. Chars C2 = C1 will be perfectly reasonable expression to
copy one Chars to another.
e. Write a complete program to test your class to see that it
does the following tasks:
i. Creates uninitialized Chars objects.
ii. Creates objects with Chars constants.
iii. Concatenates two Chars properly.
iv. Displays a desired Chars object.
4. Write a program to overload << operator such that it would take
two matrices (M1, M2) and display M1’ (transpose), M2’ and
M1*M2.
5. Define two classes Oval and circle to represent complete oval and
circle respectively. Use conversion routine to convert from one
system to other and vice versa.
6. Explain the following with example
a. What are the various ambiguities that arises in multiple
and multilevel inheritance?
b. Is there any way to inherit private members of base class
in derived class? Explain.
c. What does this pointer point to? What are its applications?
7. Write a program that can open and read a file and perform
following tasks:
a. Count number of lines.
b. Count number of words.
c. Count number of characters.
d. Calculate size of file in terms of number of objects.
e. Convert the content of file in binary form.
2