Try new tool: URL Shortener

https://res.cloudinary.com/hg6hswtwo/image/upload/v1/media/pics/oop_toolsandjobs_se2jyx_uilgm3
secondyear

Virtual Functions MCQs in Object Oriented Programming Part 2





Virtual Functions MCQs in Object Oriented Programming Part 2. This helps in competitive exams, cracking placements and SPPU online exams 2020-21.

1. 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

2. Which alternative can replace the throw statement ?
A) Exit
B) For
C) Break
D) Return
Answer D

3. Which of the following keyword can not be appered inside the class?
A) Virtual
B) Static
C) Template
D) Friend
Answer C

4. 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


5. Select the correct syntax of template:
A) Template
B) Template<>
C) Temp
D) None of these
Answer B

6. A class is generated from template class is called _______.
A) inherited class
B) derived class
C) generated class
D) subclass
Answer C

7.________ is useful when template of template is used?
A) Friend function
B) Static function
C) Typedef
D) Inheritance
Answer C

8. 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

9. 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 these
Answer B

10. 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

11. 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

12. Maximum number of template argument in function template is _______.
A) two
B) three
C) four
D) many
Answer D

13. 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

14.Template function must have at least ________ generic data type.
A) zero
B) one
C) two
D) none of these
Answer B

15.Templates provide way of abstracting ______ information.
A) type
B) data
C) method
D) access
Answer A

16. 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

17. 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

18. In the template <class T>declaration of T stands for ________.
A )integer data type
B) arbitary class
C) generic data types
D) none of these
Answer C

19. 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

20. What can be passed by non-type template parameter during compile time?
A) Int
B) Double
C) Char
D) constant expression
Answer D

21. 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

22. How many types of templates are there in c++?
A) Two
B) Three
C) Four
D) None Of These
Answer A

23. What is the task of compiler while handling template?
A) type association
B) Portability
C) code elimination
D) all of the above
Answer C

24. 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

25. Which keyword can be used with template?
A) Typename
B) operator
C) both a and b
D) None of these
Answer A


26. 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

27. What is the validity of templet parameter?
A) Inside the class
B) Inside the block
C) whole program
D) None of these
Answer B


28. Which of the following does not required installation ?
A) Non virtual member function
B) Member class
C) Function
D) All of above
Answer D


29. Which keyword is used to handle the exception ?
A) Try
B) Catch
C) Throw
D) Exception
Answer B


30. 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





Publish Your Great Work

Your AD here