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

UNIVERSITY OF HARIPUR

DEPARTMENT OF INFORMATION TECHNOLOGY

TERMINAL EXAMINATION FALL 2023

Class: BS (Software Engineering) 2nd Date: Thursday, 25th January 2024


Subject: Object Oriented Programming Instructor: Mr. Kamran Ahmad Awan
Total Time Allowed: 20 Minutes Max Marks: 20 Marks

Name: ___________________________ Roll #: ___________________________

SECTION-A

Q1. Choose the correct answer:

1. Which of the following is not allowed in C++ function overloading?


a) Different number of parameters c) Different order of parameters
b) Different types of parameters d) Different return type only
2. What is the main advantage of generic programming in C++?
a) Increases execution speed c) Code reusability
b) Improves memory usage d) Enhanced error checking
3. A template class in C++:
a) Can only be instantiated with built-in data types
b) Cannot have more than one template parameter
c) Allows for type-safe data structures d) Does not support member functions
4. Which inheritance type in C++ involves more than one base class for a derived class?
a) Single Inheritance c) Multilevel Inheritance
b) Multiple Inheritance d) Hierarchical Inheritance
5. Which principle of Object-Oriented Programming is achieved by bundling data with methods
that operate on that data?
a) Inheritance c) Encapsulation
b) Polymorphism d) Abstraction
6. A destructor in C++:
a) Is used to create an object c) Can be called manually
b) Is automatically called when an d) Can be overloaded
object is destroyed
7. When defining a template class, which keyword is essential?
a) class c) template
b) typename d) typedef
8. Function overloading is an example of:
a) Compile-time polymorphism. c) Inheritance
b) Run-time polymorphism d) Encapsulation
9. What is the correct sequence of keywords for exception handling in C++?
a) try, catch, throw c) catch, throw, try
b) throw, try, catch d) try, throw, catch
10. Templates in C++ are primarily used for:
a) Function overloading b) Error handling
c) Creating generic classes and functions
d) Defining member functions
11. In C++, which access specifier is used in inheritance to ensure that the public members of the base
class remain public in the derived class?
a) Public b) Private c) Protected d) Friend
12. A destructor in C++:
a) Is used to create an object
b) Is automatically called when an object is destroyed
c) Can be called manually d) Can be overloaded
13. In C++, a function that does not handle an exception:
a) Terminates the program
b) Passes the exception to the calling function
c) Ignores the exception d) Returns NULL
14. In C++, a static data member is initialized:
a) Every time an object of the class is created
b) Only once, when the class is first used
c) When the class constructor is called
d) When the class destructor is called
15. Which of the following is true for a template class in C++?
a) It can only be used with built-in data types.
b) It generates a separate class for each data type used.
c) It must be instantiated using specific functions.
d) It is automatically instantiated when the program starts.
16. How do you instantiate an object of a template class for a specific type in C++?
a) ClassName<Type> objectName; b) ClassName objectName<Type>;
c) Template<ClassName> objectName;
d) Template<Type> ClassName objectName;
17. Which of the following is true about the 'catch' block in C++ exception handling?
a) It must immediately follow the 'try' block
b) It can only catch exceptions of the same type as declared
c) It can catch any type of exception, regardless of the declared type
d) It is optional and may be omitted if not needed
18. In C++, which access specifier should be used to allow an inherited class to access a member of
the base class?
a) Public b) Private c) Protected d) Friend
19. Which keyword is used to throw an exception in C++?
a) throw b) catch c) try d) error
20. In C++, which keyword is used to define a method that can be overridden in a derived class?
a) virtual b) override c) extend d) super

Answer Sheet

1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
17 18 19 20

You might also like