0% found this document useful (0 votes)
11 views2 pages

Practice Questions For OOPD 24-1

Uploaded by

shubhankartiwary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Practice Questions For OOPD 24-1

Uploaded by

shubhankartiwary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Object Oriented Programming & Design - Monsoon 2023

Final Examination Questions (4-Credit)

Name of the Student:

Roll Number:

Stream:

Question Structure and Instructions


Please write your roll number on each page of the question paper above the top margin. This paper
consists of two sections:
1. The 1st section consists of 15 short conceptual questions each carrying 3 points.
2. The 2nd section consists of 6 longer questions each carrying 5 points.

1 Short Conceptual Questions (3x10=30 points)


A1 Consider the case of the following code fragment:
v e c t o r <i n t > my data ( { 0 , 5 , 1 0 } ) ;
f o r ( i n t i = my data . s i z e ( ) − 1 ; i >= 0 ; i −−) {
c o u t << my data [ i ] ;
}

Suppose we want to use a more general technique of doing the above loop, where “general” implies
that it works with other containers. How would you implement this technique? Your code must avoid
as much verbose syntax as possible.
A2 Consider a case where the output of a function is itself a function of two distinct template types. Is
there a way to do this?
A3 Suppose a company enforces a code standard where usage of templates is not allowed. Can you
implement the same functionality that templates allow in functions? If so, how?
A4 Consider a file system that allows inodes with only one level of indirection. What will be the disad-
vantage of this filesystem?
A5 Suppose a kernel designer decides that only one filesystem is sufficient, and discards use of virtual
filesystem. Can this be a functional kernel? Is there any other functionality that would be affected?
A6 Assume that we first create a vector and then a set. In each of them, you need to insert an element,
with both the positions/numbers being uniformly distributed. We decide to use first the individual
container’s insert, and then the insert algorithm. Which of them is faster and why?
A7 Consider a situation where we have installed a program called “abc”. Trying to execute it gives the
error “Permission denied”. How would you resolve the above problem? You need to explain the reason
and then give the exact command.
A8 Assume that we want to create an object of HashMap (present in STL) where the key can be either
an object of Class1 or Class2. Is this possible, and if so, what can you do to enable it?

1
A9 Consider a situation where you create a linked list using pointers. Due to a variety of performance
reasons, the programming team decides to avoid using a higher-level object such as STL containers.
Is there still a way to ensure deallocation of memory is done properly by the programmers? You must
mention the concepts and initialize one such data structure.
A10 Consider a situation where you want to write programs in the form of layers. Is inheritance the right
way to implement it? If so, give an example, If not so, explain the alternative strategy.

2 Long Questions (5 x 6 = 30 points)


B1 The Indian Railways run a variety of trains, falling into a variety of categories. The highest level of
category are the passenger and freight trains. The passenger trains are categorized as mail and express
trains, among which a limited number are also sub-categorized as superfast trains. Superfast trains
also have the attribute that they more passenger amenities than non-superfast trains. Assuming that
the train signaling system requires assigning priority based on the sub-category of trains, which is kept
track using a priority parameter. Design a class structure that can automatically compute the priority
of trains, depending on their type. You may assume that the highest priority is given to superfast,
followed by express but non-superfast, followed by mail trains, followed by freight trains.
B2 (a) Consider a program in which there are two vectors A and B on which Fast Fourier Transform
needs to be performed. The operation on A takes some tp1 time and on B takes some tp2 time, in
Python. However, the programmer decides to create threads so that they can be run concurrently.
What is the approximate running time of this program, ignoring other overheads of creating the
threads?
(b) Assume that there are two threads that run concurrently which increases the value of a global
variable x. If x was initialized to 0, what is the final value of x, if the program is written in (i)
C++, and in (ii) Python?
B3 You want to create an abstract data structure that has a key and object. Search and sort operations
always happen only by referring to the key, but the object contains other essential information. Explain
and justify the best solution in the following cases:
(a) The data type of the key can vary depending on the use case.
(b) The data type of the object can vary depending on the use case.

B4 Consider two programs P1 and P2 both of which implement sorting of arrays of ints and floats. P1
uses templates to do the sorting, whereas P2 uses function overloading to write the two functions.
Which among P1 and P2 have higher compilation time, and specify that who among P1’s int sort,
P1’s float sort, P2’s int sort and P2’s float sort are the fastest and slowest respectively? You need to
justify the reason.
B5 The Indian immigration system classifies countries into trusted and distrusted categories. Citizens of
trusted countries get a visa on arrival, whereas citizens of distrusted countries do not get. There are
also different categories of visa, such as tourist, work, education. Note that every visa must belong to
some category. Furthermore, anybody making a false claim is noted down, and further visa requests
are denied to them. Design a class structure to model the visas issued by the immigration system.
B6 In the above question, the application is considered critical, as a decision has major impact on the
security. This requires unit testing of various classes that deal with issuing of visas. How would you
go about testing each of such classes? You need to show the structure of any extra code that might be
needed.

You might also like