-->

OOP MCQ UNIT 4 FIRST PAGE



 Id 1

Question What is meaning of template parameter?

A It is used to pass a type as argument

B Used to evaluate a type

C It can of no return type

D None of the mentioned

Answer A

Marks 1

Unit IV


Id 2

Question ______Keyword is used in template.

A Class

B Typename

C Both a and b

D Using

Answer C

Marks 1

Unit IV


Id 3

Question What is scope of template parameter?

A Inside a block only

B Inside the class only

C Throughout program

D All of the above

Answer A

Marks 1

Unit IV


Id 4

Question Function overloading is also similar to which of the following

A Operator overloading

B Destructor overloading

C Constructor overloading

D Virtual function

Answer B

Marks 1

Unit IV


Id 5

Question Generic programming is approach of______________________which are applicable for 

all types

A Generalised algorithm

B Pseude algorithmC Both a and b

D None of the above

Answer A

Marks 1

Unit IV


Id 6

Question Template are of types

A Function template

B Class template

C Both a and b

D None of the above

Answer C

Marks 1

Unit IV


Id 7

Question Class template can be created using________syntax.

A Template<class T>class classname

B Template<class T1,class T2> class classname

C Both a and b

D None of the above mentioned

Answer C

Marks 1

Unit IV


Id 8

Question Syntax for creating a function template is

A Template<typename t>returntype function name

B Template<class T> returntype function name

C Both a and b

D None of the above mentioned

Answer C

Marks 1

Unit IV


Id 9

Question Pick up the correct statement

i)template allow us to define generic classes and functions

ii)template support generic programming

iii)function template overloading is possible

A i only

B i and ii only

C ii and iii only

D i, ii and iii

Answer DMarks 1

Unit IV


Id 10

Question Template function can be overloaded

A True

B False

C

D

Answer A

Marks 1

Unit IV


Id 11

Question Why we use :: template-template parameter?

A binding

B rebinding

C both a &b

D none of these

Answer C

Marks 1

Unit IV


Id 12

Question Which of the things does not require instantiation?

A functions

B non virtual member function

C member class

D all of the mentioned

Answer D

Marks 1

Unit IV


Id 13

Question A template provides a convenient way to make a family of

A variables.

B functions

C classes

D B and C

Answer D

Marks 1

Unit IV


Id 14

Question Templates automatically create different versions of a function, depending on user input.

A TRUEB FALSE

C

D

Answer B

Marks 1

Unit IV


Id 15

Question A template class

A is designed to be stored in different containers.

B works with different data types.

C generates objects which must all be identical.

D generates classes with different numbers of member functions.

Answer B

Marks 1

Unit IV


Id 16

Question There can be more than one template argument.

A TRUE

B FALSE

C

D

Answer A

Marks 1

Unit IV


Id 17

Question Actual code for a template function is generated when

A the function declaration appears in the source code.

B the function definition appears in the source code.

C a call to the function appears in the source code.

D the function is executed at runtime.

Answer C

Marks 1

Unit IV


Id 18

Question An exception is typically caused by

A the programmer who writes an application‟s code.

B the creator of a class who writes the class member functions.

C a runtime error.

D an operating system malfunction that terminates the program.

Answer C

Marks 1

Unit IV


Id 19

Question Statements that might cause an exception must be part of a catch block.

A TRUE

B FALSE

C

D

Answer B

Marks 1

Unit IV


Id 20

Question Exceptions are thrown

A from the catch block to the try block.

B from a throw statement to the try block.

C from the point of the error to a catch block.

D from a throw statement to a catch block.

Answer D

Marks 1

Unit IV


Id 21

Question A statement that throws an exception does not need to be located in a try block.

A TRUE

B FALSE

C

D

Answer B

Marks 1

Unit IV


Id 22

Question The following is/are errors for which an exception would typically be thrown:

A An excessive amount of data threatens to overflow an array.

B new cannot obtain the requested memory.

C A power failure shuts down the system.

D A and B

Answer D

Marks 1

Unit IV


Id 23

Question Additional information sent when an exception is thrown may be placed in

A the throw keyword.

B the function that caused the error.

C the catch block.D an object of the exception class.

Answer D

Marks 1

Unit IV


Id 24

Question A program can continue to operate after an exception has occurred.

A TRUE

B FALSE

C

D

Answer A

Marks 1

Unit IV


Id 25

Question What is the output of following program?

#include <iostream>

using namespace std;

int main()

{

int x = -1;

try {

cout <<"Inside try \n";

if (x <0)

{

throw x;

cout <<"After throw \n";

}

}

catch (int x ) {

cout <<"Exception Caught \n";

}

cout <<"After catch \n";

return 0;

}

A Inside try

Exception Caught

After throw

After catch

B Inside try

Exception Caught

After catch

C Inside tryException Caught

D Inside try

After throw

After catch

Answer B

Marks 2

Unit IV


Id 26

Question What is the advantage of exception handling?

1) Remove error-handling code from the software's main line of code.

2) A method writer can chose to handle certain exceptions and delegate others to the 

caller.

3) An exception that occurs in a function can be handled anywhere in the function call 

stack. 

A Only 1

B 1, 2 and 3

C 1 and 3

D 1 and 2

Answer B

Marks 2

Unit IV


Id 27

Question What should be put in a try block?

1. Statements that might cause exceptions

2. Statements that should be skipped in case of an exception

A Only 1

B Only 2

C Both 1 and 2

D None of the above

Answer C

Marks 1

Unit IV


Id 28

Question What is the output of following program

#include<iostream>

using namespace std;

class Base {};

class Derived: public Base {};

int main()

{

 Derived d; try {

 throw d;

 }

 catch(Base b) {

 cout<<"Caught Base Exception";

 }

 catch(Derived d) {

 cout<<"Caught Derived Exception";

 }

 return 0;

}

A Caught Derived Exception

B Caught Base Exception

C Caught Derived Exception

Caught Base Exception

D Compiler Error

Answer B

Marks 1

Unit IV


Id 29

Question What is the output of following program?

#include <iostream>

using namespace std;

int main()

{

 try

 {

 throw 10;

 }

 catch (...)

 {

 cout <<"default exception\n";

 }

 catch (int param)

 {

 cout <<"int exception\n";

 }

 return 0;

}

A default exception

B int exception

C default exceptionint exception

D Compiler Error

Answer D

Marks 1

Unit IV


Id 30

Question What is the output of following program?

#include <iostream>

using namespace std;

class Test {

public:

 Test() { cout <<"Constructing an object of Test "<<endl; }

 ~Test() { cout <<"Destructing an object of Test " <<endl; }

};

int main() {

 try {

 Test t1;

 throw 10;

 } catch(int i) {

 cout <<"Caught "<<i <<endl;

 }

}

A Caught 10

B Constructing an object of Test

Caught 10

C Constructing an object of Test

Destructing an object of Test

Caught 10

D Compiler Errror

Answer C

Marks 2

Unit IV


Id 31

Question What happens in C++ when an exception is thrown and not caught anywhere like 

following program?

#include <iostream>

using namespace std;

int fun() throw (int)

{ throw 10;

}

int main() {

 fun();

 return 0;

}

A Compiler error

B Abnormal program termination

C Program doesn't print anything and terminates normally

D None of the above

Answer B

Marks 1

Unit IV


Id 32

Question Which alternative can replace the throw statement ?

A Exit

B For

C Break

D Return

Answer D

Marks 1

Unit IV


Id 33

Question Which of the following keyword can not be appered inside the class?

A Virtual

B Static

C Template

D Friend

Answer C

Marks 1

Unit IV


Id 34

Question What is template?

A Template is formula for creating a generic class

B Template is used to manipulate class

C Template is used for creating functions

D None of these

Answer A

Marks 1

Unit IV


Id 35

Question Select the correct syntax of template:

A Template

B Template<>

C Temp

D None of these

Answer B

Marks 1

Unit IV


Id 36

Question A class is generated from template class is called _______.

A inherited class

B derived class

C generated class

D subclass

Answer C

Marks 1

Unit II


Id 37

Question ________ is useful when template of template is used?

A Friend function

B Static function

C Typedef

D Inheritance

Answer C

Marks 1

Unit IV


Id 38

Question Which of the C++ feature allows you to create classes that are dynamic for using data 

types?

A Templates

B Inheritance

C Polymorphism

D Information hiding

Answer A

Marks 1

Unit IV


Id 39

Question A function template means _______.

A creating a function having exact type

B creating a function without having to specify exact type

C both a and b

D none of theseAnswer B

Marks 1

Unit IV


Id 40

Question Which of the following is used to describe the function using placeholder type?

A Template type parameter

B Template parameter

C Template type

D None of these

Answer A

Marks 1

Unit IV


Id 41

Question String template is used _____.

A to replace a string.

B to replace a string with another string

C to delete a string

D none of these

Answer B

Marks 1

Unit IV


Id 42

Question Maximum number of template argument in function template is _______.

A two

B three

C four

D many

Answer D

Marks 1

Unit IV


Id 43

Question Template function must have

A one or more than one argument

B zero argument

C only one argument

D at least two arguments

Answer A

Marks 1

Unit IV


Id 44

Question Template function must have at least ________ generic data type.A zero

B one

C two

D none of these

Answer B

Marks 1

Unit IV


Id 45

Question Templates provide way of abstracting ______ information.

A type

B data

C method

D access

Answer A

Marks 1

Unit IV


Id 46

Question If you create instantiation of a class template with an int and then create a second 

instantiation with a double then

A once the function is used for one data type it becomes unavailable for other type

B you can not perform this kind of operation in C++

C you must precede each function call with the word int or double

D none of these

Answer C

Marks 1

Unit IV


Id 47

Question If templates were removed from C++,Which of the following will be true?

I. Some algorithms could no longer be implemented

II. Any particular algorithms could still be implemented but often less elegantly.

A Only I is true

B Only II is true

C Both I and II is true

D None of these

Answer D

Marks 1

Unit 4


Id 48

Question In the template <class T>declaration of T stands for ________.

A integer data type

B arbitary class

C generic data typesD none of these

Answer C

Marks 1

Unit IV


Id 49

Question What is the meaning of template parameter?

A It is used to pass a type as argument

B It is used to evalute a type

C It has no return type

D None of these

Answer A

Marks 1

Unit IV


Id 50

Question What can be passed by non-type template parameter during compile time?

A Int

B Double

C Char

D constant expression

Answer D

Marks 1

Unit IV


Id 51

Question Choose the correct statement from the following:

A Template function will take long time to execute

B Template functions are written when you want to have only one code for many different 

types

C due to template function the duplicate code will get increased

D None of these

Answer B

Marks 1

Unit IV


Id 52

Question How many types of templates are there in c++?

A Two

B Three

C Four

D None Of These

Answer A

Marks 1

Unit IV


Id 53

Question What is the task of compiler while handling template?

A type association

B Portability

C code elimination

D all of the above

Answer C

Marks 1

Unit IV


Id 54

Question What should be the name of the parameter that the template should take?

A same as class

B same as function

C same as template

D none of these

Answer C

Marks 1

Unit IV


Id 55

Question Which keyword can be used with template?

A Typename

B operator

C both a and b

D None of these

Answer A

Marks 1

Unit IV


Id 56

Question Which of the following describes a difference between template function and

template class in c++?

A The compiler determines the type of a template function's arguments, but

the types of template classes must be stated explicitly when declaring objects

B template functions cannot be defined for user-defined types, but template classes can

C template classes cannot be defined for user-defined types,but

templatefunctions can.

D None Of These

Answer A

Marks 1

Unit IV


Id 57

Question What is the validity of templet parameter?

A Inside the classB Inside the block

C whole program

D None of these

Answer B

Marks 1

Unit IV


Id 58

Question Which of the following does not required installation ?

A Non virtual member function

B Member class

C Function

D All of above

Answer D

Marks 1

Unit IV


Id 59

Question Which keyword is used to handle the exception ?

A Try

B Catch

C Throw

D Exception

Answer B

Marks 1

Unit IV


Id 60

Question What is the use of the keyword finally ?

A It is used at the start of the program for handling all the exceptions

B It is used at the end of the program to handle all the exceptions

C It can be used anywhere in the program to handle all the exceptions

D None of these

Answer B

Marks 1

Unit IV


Id 61

Question Which of the following most preferred way of throwing and handling exception?

A Throw by value and catch by reference

B Throw by reference and catch by value

C Throw by value and catch by value

D None of these

Answer A

Marks 1

Unit IV


Id 62

Question Which of the following is the most general exception handler that catches exception of 

any type?

A Catch(std::exception)

B Catch(std:any_exception)

C Catch(...)

D Catch()

Answer C

Marks 1

Unit IV


Id 63

Question Which of the following causes an exception

A Missing parenthesis in main()

B Calling a function which is not present

C A syntax error 

D a run time error

Answer D

Marks 1

Unit IV


Id 64

Question Which block should be placed after try block ?

A Throw

B Catch 

C both a or b

D none of these

Answer C

Marks 1

Unit IV


Id 65

Question Choose the correct statement

A Exception are not suitable for critical points in the program

B Exception are suitable for critical points in the program

C Both a&b

D None of these

Answer A

Marks 1

Unit IV


Id 66

Question In C++ program handling, a try block must be followed by _____catch blocks

A exactly oneB one or more

C exactly two

D none of these

Answer B

Marks 1

Unit IV


Id 67

Question The process of handling the actual exception occurs _________

A inside the program

B outside the program

C both a &b

D none of these

Answer B

Marks 1

Unit IV


Id 68

Question Which of the following is used to check the error in the block?

A Try

B Throw

C Catch

D None of these

Answer A

Marks 1

Unit IV


Id 69

Question What should be present when throwing object ?

A Constructor

B Destructor

C copy constructor

D none of these

Answer C

Marks 1

Unit IV


Id 70

Question For handling the exception in C++ _______ are used

A catch handlers

B exception handlers

C Pointers

D none of these

Answer B

Marks 1Unit IV


Id 71

Question For handling the exceptions in C++ _________ is used .

A handler function

B terminate function

C both a &b

D none of these

Answer B

Marks 1

Unit IV


Id 72

Question How many parameters does the throw expression can have ?

A 0

B 1

C 2

D 3

Answer B

Marks 1

Unit IV


Id 73

Question What kind of exceptions are used in C++

A Handled

B Unhandled

C Static

D Dynamic

Answer B

Marks 1

Unit IV


Id 74

Question What will happen when exception is uncaught?

A Arise an error

B program will run

C execute in a loop

D none of these

Answer A

Marks 1

Unit IV


Id 75

Question Choose the correct statement

A A function can throw any type of exceptionB a function can throw an exception of certain type only

C A exception can't throw any type of exception

D none of these

Answer B

Marks 1

Unit 4


Id 76

Question What fuunction will be called when we have uncaught exception?

A Catch

B Throw

C Terminate

D none of these

Answer C

Marks 1

Unit IV


Id 77

Question What will happen when a programs throws any other of exception other than specified ?

A still execute

B Terminate

C raise an error

D none of these.

Answer C

Marks 1

Unit IV


Id 78

Question Which statement is used to catch all types of exceptions?

A catch()

B catch(Test t)

C catch

D none of these

Answer D

Marks 1

Unit IV


Id 79

Question Which keyword can be used as a template

A Exception

B Typename

C both a & b

D Function

Answer B

Marks 1

Unit IV


Id 80

Question An Exception is thrown using _____________keyword in cpp

A Throws

B Throw

C Threw

D Thrown

Answer B

Marks 1

Unit IV


Id 81

Question Which parameter is legal for non-type template?

A pointer to member

B object

C class

D none of these

Answer A

Marks 1

Unit IV


Id 82

Question Which of the things does not require instantiation?

A functions

B Non virtual member function

C member class

D all of these

Answer D

Marks 1

Unit IV


Id 83

Question Which of the following permits function overloading on c++?

A Data Type

B Number of arguments

C A &B both

D none of these

Answer C

Marks 1

Unit IV


Id 84

Question Function overloading is also similar to which of the following?

A Operator Overloading

B Constructer overloading

C Destructor overloadingD none of the above

Answer B

Marks 1

Unit IV


Id 85

Question Which is dependent on template parameter

A base class

B abstract class

C method

D none of the above

Answer A

Marks 1

Unit IV


Id 87

Question How to declare a template?

A Tem

B Temp

C Template<>

D none of these

Answer C

Marks 1

Unit IV


Id 88

Question What may be the name of parameter that the template should take?

A same as template

B same as class

C same as function

D none of these

Answer A

Marks 1

Unit IV


Id 89

Question Which is used to handle the exceptions in c++?

A catch handler

B handler

C exception handler

D all of these

Answer B

Marks 1

Unit IV


Id 90

Question Which is called on allocating the memory for array of objects?

A Function 

B Method

C Destructor

D Constructor

Answer D

Marks 1

Unit IV


Id 91

Question Which value is placed in the base class?

A Inherited value

B Derived value

C Default type values

D Both a and b

Answer C

Marks IV

Unit IV


Id 92

Question Which is used to get the input during runtime?

A cout

B cin

C Template

D All of the above

Answer B

Marks 1

Unit IV


Id 93

Question __________is used to perform the generic programming.

A Class

B Template

C Function 

D Inheritance

Answer All of the above

Marks B

Unit IV


Id 94

Question A template can be considered as a kind of macros

A True

B False

C

D

Answer AMarks 1

Unit IV


Id 95

Question We can not define more than 2 placeholder in class/function template.

A False

B True

C

D

Answer A

Marks 1

Unit IV


Id 96

Question When template is defined with parameter that would be replaced by specified _______at 

the time of actual use of class or function.

A Keyword

B Operator

C Datatype

D None of the above mentioned

Answer C

Marks IV

Unit IV


Id 97

Question Templates sometimes called as ___________

A Parameterized classes

B Parameterized function

C Both a and b

D None of the above mentioned

Answer C

Marks 1

Unit IV


Id 98

Question Exceptions are of type

A Synchronous

B Asynchronous

C Both a and b

D None of the above mentioned

Answer C

Marks 1

Unit IV


Id 99

Question “out-of-range”, “overflow” are the type of exceptionsA Asynchronous

B Synchronous

C Default

D None of the above

Answer B

Marks 1

Unit IV


Id 100

Question The most type of error--------.

A Logical error

B Syntactic error

C Both a and b

D Class 

Answer C

Marks 1

Unit IV



0 Comments