Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Unit 4 and 5 OODP QB

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

SRMINSTITUTE OF SCIENCE AND TECHNOLOGY

Ramapuram Campus, Bharathi Salai, Ramapuram, Chennai - 600089

FACULTY OF ENGINEERING AND TECHNOLOGY

DEPARTMENT OF COMPUTER SCIENCE AND


ENGINEERING

QUESTIONBANK

DEGREE / BRANCH: B.Tech CSE, All Specializations, EKE

III SEMESTER

SUB CODE – SUBJECT NAME


18CSC202J - OBJECT ORIENTED DESIGN AND PROGRAMMING

Regulation 2018

AcademicYear 2020-21 (ODD SEMESTER)


UNIT IV
Generic – Templates : Introduction - Function Template – Example programs : Function Templates - Class Template
– Example programs : Class Templates – Exceptional Handling : try and catch – Multilevel exceptional – throe and
throws – finally – User defined exception – Example programs using C++ - Dynamic modelling : Package Diagram –
UML Component diagram – Deployment Diagram – Example : Package, Deployment, Component diagram.
PART-A (Multiple Choice Questions)
Q. Questions Course Competence
No Outcome BT Level
1 The STL can be used as a standard approach for-----------
a) Storing and sorting
b) Storing and processing data CO3 1
c) data processing only
d) storing only
2 Name the Container which uses both stack and queue.
a) storage
b) linked list CO3 1
c) queuing
d) Deque
3 Identify the characteristics of vector container.
a) Relocating, expandable array
b) Fixed size CO3 2
c) Doubly linked list
d) link vector
4 Associative container uses---------to access data.
a) queue
b) Keys CO3 1
c) stack
d) string
5 Class templates are generally used for--------
a) Data storage
b) debug CO3 1
c) fixed data type
d) storage
6 In UML, Templates are also called as--------
a) container
b) Modified CO3 1
c) Parameterized
d) generic
7 Identify the validity of template parameters?
a) inside that block only
b) inside the class CO3 2
c) whole program
d) inside the main class
8 Identify which among the following is not correct.
a) template <class T> func(T x) {}
b) template <class T> class myObject {};
CO3 2
c) template <class T> class myObj { template <class R> memFunc() {}
};
d) All of the above are correct
9 Examine whether templates are conceptually related to
polymorphism? CO3 2
a) Not Related
b) Only when the template types are objects
c) Yes, but compile-time polymorphism
d) Yes, but run-time polymorphism
10 Identify an invalid template declaration.[L2, R5-683]
a) template <int x> int func() {return x;}
b) template <double x> double func() {return x;} CO3 2
c) template <typename x> void func(x t) {}
d) It is not possible in CPP to restrict a function
11 Explore the correct statement about string template?
a) It is used to replace a string.
b) It is used to replace a string with another string at runtime. CO3 2
c) It is used to delete a string.
d) None of the above
12 ___________type of program can be included in try block?
a) static memory allocation
b) dynamic memory allocation CO4 1
c) const reference
d) pointer
13 ---------statement is used to catch all types of exceptions.
a) catch()
b) catch(Test t) CO4 1
c) catch(…)
d) no one of the mentioned
14 The ------------ class name must be included in the class in which it
is
located.
a) try CO4 1
b) Exception
c) catch
d) template
15 Select the ways to represent nodes in a deployment diagram?
a) Nodes instances are underlined identifiers of the form name:type
b) The name may be left off, indicating an unnamed instance of the type
CO5 1
c) The type may be left off, indicating a named instance with an
unspecified type
d)All of the mentioned
16 ___ __ specifies additional detail about UML element.
a) Stereotype
b) container CO5 1
c) associative container
d) data processing
17 -------- is visible only to its containing package and to its nested
a) package.
b) protected CO5 1
c) public
d) Private package
18 Notation is used to specify the required and provided interfaces of
the components. The interfaces between the components are
named
CO5 1
as----
a) Assembly connectors
b) cooling controllers
c) Environmental
controller
d) Plan analyst
19 List the 3 essential elements of a deployment diagram.
a) Artifacts, nodes and connections.
b) stack, queue, deque CO5 1
c) memory, database, connections
d) package, element, deployment
20 Activity, use case diagram, collaboration diagram and sequence
diagram are categorized as ______________.
a) non-behavioral diagrams
CO5 1
b) non structural diagrams
c) structural diagrams
d) Behavioral diagrams
21 Recognize which diagram is used to distribute files, libraries and
tables across topology of hardware?
a) Deployment diagrams
CO5 2
b) use case diagrams
c) sequence diagrams
d) collaboration diagrams
22 List the essentials in package diagram
a) Package notation, element visibility, dependency relationship
b) package notation, sequence, dependency relationship CO5 1
c) Dependency, element visibility
d) package, deployment, sequence
23 Good packages are---------coupled and highly cohesive among the
elements in package.
a) Tightly
CO5 1
b) highly
c) loosely
d) semi
24 Identify the core element of UML in the below figure?

CO5 2
a) Node
b) Interface
c) Class
d) Component
25 Recognize the UML diagram shown below?

CO5 2

a) Component
b) Deployment
c) Use case
d) DFD

PART B (4 Marks)
1 What do you mean by Generic Programming? What are its advantages CO3 1
and state few applications?
2 Define a Class Template. Write a suitable example program. CO3 2
3 What is a Function Template? Illustrate with a suitable example
CO3 2
program.
4 What do you mean by Overloaded Function Template? What are the
CO3 1
rules to be followed to select a suitable template?
5 Distinguish between overloaded functions and function templates CO3 2
6 What is the need for template function in C++? What are the
advantages? CO3 1

7 Give the differences between Class template and Function template. CO3 2
8 What is an exception? How it is handled in C++? CO4 1
9 Write a program to demonstrate the concept of rethrowing an
exception. CO4 3

10 What are the two kinds of exception? CO4 1


11 Illustrate multiple catch statements with a suitable example. CO4 2
12 When should a function throw an exception? Give an example to
illustrate CO4 2
it.
13 What is uncaught_exception() function? why do we need it? CO4 2
14 When do we need multiple catch Handlers? Give an example. CO4 2
15 What are standard exceptions? List the types of exception and specify
the CO4 1
position when it was generated?
16 What is a component diagram and state its artifacts. CO5 1
17 Define Deployment diagram. State the artifacts to be identified before
drawing a Deployment diagram. CO5 1

18 What are the uses of the Component diagram and Deployment


diagram? CO5 2

19 Give the notations of Component diagram and Deployment Diagram CO5 1


20 Define a Package Diagram. Give the advantages of using a Package
diagram. CO5 1

PART C (12 Marks)


1 Discuss in detail on Class Template with a suitable example. CO3 2
2 What is a Function Template? Discuss in detail with a suitable
CO3 2
program.
3 Write a program which generate a template class by which one can
CO3 3
perform
integer type data addition and float type data addition.

4 Discuss in detail on Overlading Function template. Illustrate it with a


CO3 2
suitable program.
5 Explain how the Class Template can be used with Operator
overloading CO3 2
with a program.
6 Write a C++ program to develop a Simple Calculator to perform
arithmetic CO3 3
operations using Class Template.
7 What is an exception? How it is handled in C++ programs? Explain
how
CO4 2
the control is transferred when exceptions occur during programs
execution. Write a program to illustrate exception handling.
8 Write a program to show how to restrict the types of exceptions that
can be CO4 3
thrown by a function.
9 Write a program to show how to rethrow an exception. CO4 3
10 Write a C++ program to demonstrate the use of try, catch , throw and
nested CO4 3
try.
11 What is a user defined exception. Write down the scenario where we
CO4 2
require user defined exceptions.
12 When do we need multiple catch blocks for a single try block? Write a
CO4 2
program to illustrate it.
13 Explain in detail on the use of Multiple catch statements in a program
with
a suitable example. Discuss the importance of “catch all exception” CO4 2
with a
program.
14 Explain Deployment Diagram with a suitable example. CO5 2
15 What is a Package Diagram. Illustrate it with a suitable example. CO5 2
16 Draw the Component, Deployment and package diagram for the ATM
Banking system. Explain the system with the notations used in each CO5 3
diagram.
17 Design the Component, Deployment and package diagram for the
Airline
CO5 3
Reservation system. Explain the system with the notations used in each
diagram.
18 Explain the Component, Deployment and package diagram for the
Course
CO5 3
Registration system with a neat diagram Illustrate the system with the
notations used in each diagram.
19 Discuss in detail on Component Diagram with a suitable example. CO5 2
20 Draw the Component, Deployment and package diagram for the Online
Shopping system. Explain the system with the notations used in each CO5 3
diagram.
UNIT V

STL: Containers, sequence and Associative containers, Sequence Containers : Vector,


List, Deque , Array, STL - stack -Associative Containers - Map - MultiMap - Iterator
and Specialized Iterator - Functions of Iterator - Algorithms -find() -count() - sort() -
search() - merge() -function object: for_each, transform - streams and Files
:introduction - classes and errors- disk file handling -reading and writing
PART-A (Multiple Choice Questions)
Q. Questions Course Competence
No Outcome BT Level

1 What kind of library is Standard Template


Library?
a) Polymorphic
b) Generic CO6 BT1
c) Both Polymorphic & Generic
d) None of the mentioned

Ans:b
2 To what type of object does the container can be
instantiated?
a. int
b. float
CO6 BT1
c. double
d. any type of object

Ans:d
3 What type of class template is list?
a. Class-based
b. Node-based
CO6 BT2
c. Method-based
d. None of the mentioned
Ans:b
4 What type of access does deque and vector provide?
a. Linear access
b. Parallel access
CO6 BT2
c. Random access
d. None of the mentioned
Ans:c
5 Where does the vector add the item?
a. End
b. Insert
CO6 BT1
c. Middle
d. None of the mentioned
Ans:a
6 Which are not full container classes in C++?
a. Sequence container CO6 BT1
b. Associative container
c. Container adaptor
d. None of the mentioned
Ans:c
7 What is the lifetime of the element in container?
a. Whole program
b. Outside the block
CO6 BT1
c. Everywhere
d. Only on that container
Ans:d
8 Which operator is used to insert the data into file?
a. >>
b. <<
CO6 BT1
c. <
d. None of the Above
Ans: b
9
Which function is used to position back from the end of
file object?
a. seekg
b. seekp CO6 BT1
c. both seekg&seekp
d. None of the Above
Ans:a
10 How many objects are used for input and output to a
string?
a. 1
b. 2 CO6 BT2
c. 3
d. 4
Ans:c
11
Which is used to handle the exceptions in c++?
a. catch handler
b. handler CO6 BT1
c. exception handler
d. None of the Mentioned
Ans:c
12 Which type of program is recommended to include in try
block?
a. static memory allocation CO6 BT1
b. dynamic memory allocation
c. const reference
d. pointer

Ans:b
13 Which statement is used to catch all types of exceptions?
a. catch()
b. catch(Test t)
c. catch(…) CO6 BT1
d. None of the Above
Ans:c

14 What do Associate containers implement?


a. Arrays
b. Associative arrays
CO6 BT1
c. Functional Arrays
d. Static arrays
Ans: b
15
By using which of the following the elements in the
associate container can be efficiently accessed?
a. Key
b. Position CO6 BT3
c. Both Key & Position
d. Value
Ans: a
16
How many items are presented in the associate
container?
a. 2
b. 3 CO6 BT1
c. 4
d. 5
Ans: c
17
What are the containers?
a. Containers store objects and data
b. Containers stores all the algorithms CO6 BT1
c. Containers contain overloaded functions
d. Containers contain set of Iterators
Ans: a
18 In how many categories, containers are divided?
a. 1
b. 2 CO6 BT2
c. 3
d. 4
19 What are the Sequence Containers?
a. Containers that implements data structures which can
be accessed sequentially
b. Containers that implements sorted data structures for
fast search in O(logn)
CO6 BT2
c. Containers that implements unsorted(hashed) data
structures for quick search in O(1)
d. Containers that implements data structures which
can be accessed non-sequentially
Ans:a
20 How many Sequence Containers are provided by C++?
a. 2
b. 3
CO6 BT1
c. 4
d. 5
Ans:d
21 What is the Standard Template Library?
a) Set of C++ template classes to provide common
programming data structures and functions
b) Set of C++ classes
CO6 BT1
c) Set of Template functions used for easy data structures
implementation
d) Set of Template data structures only
Ans:a
22 What are Unordered Associative Containers?
a) Containers that implements data structures which can be
accessed sequentially
b) Containers that implements sorted data structures for fast
search in O(logn)
CO6 BT1
c) Containers that implements unsorted(hashed) data
structures for quick search in O(1)
d) Containers that implements data structures which can be
accessed non-sequentially
Ans:c
23 What are Iterators?
a) Iterators are used to iterate over C-like arrays
CO6 BT1
b) Iterators are used to iterate over pointers
c) Iterators are used to point memory addresses of STL
containers
d) Iterators are used to iterate over functions
Ans: C
24 Which header file is used for Iterators?
a) <iterator>
b) <algorithm>
CO6 BT1
c) <iter>
d) <loopIter>
Ans:a
25 Consider that the variable str is of type std:string. What is
the correct way to get the C-style string from str?
A. Cast str to const char* as in((const char*)&str)
B. Use str.get_c_style_string() CO6 BT2
C. Use str.c_str()
D. Use str.data()
Ans:C
PART B (4 Marks)
1 What are containers in C++ STL? CO6 BT1
2 What are the 3 entities of STL in C++? CO6 BT1
3 What is true about his statement in C++?
CO6 BT2
std::vector<int> vecInts(5);
4 Justify your answers Is it possible to initialize any Vector
CO6 BT1
with an Array in C++?
5 Difference between Vector Vs List CO6 BT2
6 Different Ways to Initialize a List and elaborate them CO6 BT2
7 How to erase elements from List using Iterators CO6 BT1
8 How to Remove Elements from a List while Iterating CO6 BT1
PART C (12 Marks)
1 Give syntax of and explain various functions related
to ifstream and ofstream classes: seekp(), CO6 BT3
getline(),hide(),tail().
2 Explain the use of ifstream and ofstream classes for
CO6 BT3
file input and output.
3 Explain the file operation functions in C++ to
manipulate the position of file pointers in a random CO6 BT3
access file.
4 What is the purpose of push_back(), push_front(),
CO6 BT2
pop_back() and pop_front() functions of a list.
5 What does this function do?

void func() { CO6 BT2

std::vector<std::string> vecOfString(5, "Hi");


for (std::string str : vecOfStr)
std::cout << str << std::endl;
}

Note:

1. BT Level – Blooms Taxonomy Level

2. CO – Course Outcomes

BT1 –Remember BT2 – Understand BT3 – Apply BT4 – Analyze BT5 – Evaluate BT6 – Create

You might also like