DR B R Ambedkar National Institute of Technology, Jalandhar CSPC-203, Object Oriented Programming End Semester Examination, Dec 2020

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Roll No…………………..

Dr B R Ambedkar National Institute of Technology, Jalandhar


B Tech (Computer Science and Engineering)
CSPC-203, Object Oriented Programming
End Semester Examination, Dec 2020
Duration: 02 Hours Max. Marks: 40 Date: 3rd Dec 2020

Marks Distribution & Mapping of Questions with Course Outcomes (COs)


Question Number 1 2 3 4 5 6 7
Marks 5 10 5 5 5 5 5
CO No. 4 1 2 2 2 3 4
Learning Level 3 1 2 2 3 1 2

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. Write a program that would read m (number of hats) and n (number of


boxes) from a file. The program will write the number of ways in the
file, with which the hats can be placed in boxes where size of box is
written in an array which represents the number of hats a box can have.
It should also write in file all possible combinations in which hats can
be placed in different boxes.
2. Explain the following with example:
a. Call by reference vs call by address.
b. Static function and static variable.
c. Differentiate between the constant declared with const
and with preprocessor directive #define.
d. Give an example of giving the effect of default argument
without using it.

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

You might also like