Presentation is loading. Please wait.

Presentation is loading. Please wait.

C ++ MULTIPLE CHOICE QUESTION

Similar presentations


Presentation on theme: "C ++ MULTIPLE CHOICE QUESTION"— Presentation transcript:

1 C ++ MULTIPLE CHOICE QUESTION

2 Check your Knowledge Press to Start

3 1. The default executable generation on UNIX for a C++ program is ___
a.exe a a.out out.a

4 2. ____ is also called as abstract class.
Virtual class Pure virtual class Derive class None of these

5 3. Define pure virtual function?
Function which does not have definition of its own. Function which does have definition of its own. Function which does not have any return type. None of these

6 4. Identify the correct statement?
A) We cannot make an instance of an abstract base class B) We can make an instance of an abstract base class Both A & B None of the mentioned

7 5. Abstract class is used:
A) Base class only B) Derived class Both A and B None of the mentioned

8 6. Which of the following correctly declare an array?
Int array[10]; Array array []; Arr array[]; None of these

9 7. An array is: Series of element of same type Series of element
Series of element of different type None of these

10 8. To access the 100th element in a array. What should we write?

11 9. To access the first element of the array we should write:

12 10. What will be the output of this program?
#include <stdio.h> using namespace std; int array1[] = {1200, 200, 2300, 1230, 1543}; int array2[] = {12, 14, 16, 18, 20}; int temp, result = 0; int main() { for (temp = 0; temp < 5; temp++) { result += array1[temp]; } for (temp = 0; temp < 4; temp++) { result += array2[temp]; } cout << result; return 0; } 6553 6533 64522 12200

13 11. What will be the output for this program?
#include <stdio.h> using namespace std; int main () { Int array[] = {0, 2, 4, 6, 7, 5, 3}; int n, result = 0; for (n = 0; n < 8; n++) { result += array[n]; } cout << result; return 0; } 2 20 27 30

14 12. What is meaning of following declaration? int(*p[5])();
p is pointer to function p is array of pointer to function. p is pointer to such function which return type is array. p is pointer to array of function

15 13. A 32 bit generic pointer has:
2 bits 4 bits 6 bits 8 bits

16 14. What is the output of this program?
#include <iostream> using namespace std; int main() { int a[2][4] = {3, 6, 9, 12, 15, 18, 21, 24}; cout << *(a[1] + 2) << *(*(a + 1) + 2) << 2[1[a]]; return 0; Compile time error

17 15. What is the output of this program?
#include <iostream> using namespace std; int main() { int arr[] = {4, 5, 6, 7}; int *p = (arr + 1); cout << *p; return 0; 4 5 6 7

18 16. What is the output of this program?
#include <iostream> using namespace std; int main() { int arr[] = {4, 5, 6, 7}; int *p = (arr + 1); cout << arr; return 0; } 4 5 Address of art 6

19 17. What is template? A template is used to manipulate the class
A template is used for creating the attributes None of the mentioned

20 18. Select the correct statement about string template?
Used to replace string Used to replace string with another Used to delete a string None of mentioned

21 19. Which one is correct declaration of template?
None of the mentioned

22 20. What keyword we used to handle an exception?
Try Throw Catch None of the mentioned

23 21. Which keyword we use to catch an exception?
Throw Catch try None of these

24 22. Finally keyword is used for:
A) It used to execute at the starting of the program B) It will be executed at the end of the program even if the exception raised. Both a and b None of the mentioned

25 23. In nested try blocks, if both inner and outer catch handlers are not able to handle the exception, then ________. Compiler executes only executable statements of main(). Compiler issues compile time errors about it. Program will be executed without any interrupt. Program will be terminated abnormally.

26 24. Return type of uncaught_exception() is ________________ .
int bool char * double

27 25. Can we write throw clause inside catch handler?
Yes No

28 26. Which of the following statements are true about Catch handler?
It must be placed immediately after try block T. It can have multiple parameters. There must be only one catch handler for every try block. Generic catch handler can be placed anywhere after try block.

29 27. Catch handler can have multiple parameters.
False True

30 28. What is the output of this program?
#include <iostream> #include <exception> using namespace std; int main () { try { int* myarray = new int[1000]; cout << "allocated"; } catch (exception& e) { cout << "Standard exception: " << e.what() << endl; return 0; Allocated Standard exception Depend on the memory Error

31 29. Which statement is true about user defined exception?
Inheriting and overriding exception class functionality. Overriding class functionality. Inheriting class functionality None of the mentioned

32 30. Which exception is thrown by dynamic_cast?
Bad_cast bad_typeid bad_exception bad_alloc

33 31. An exception can be of only built-In type.
True False

34 32. Irrespective of exception occurrence, catch handler will always get executed.
True False

35 33. What will happen when an exception is uncaught?
Error arise Program will run Execute continuously None of the mentioned

36 34. _____ can catch all type of exceptions?
Catch-all handler Catch handler Catch none handler None of these

37 35.  If inner catch handler is not able to handle the exception then__________ .
Compiler will look for outer try handler Program terminates abnormally Compiler will check for appropriate catch handler of outer try block None of these

38 36. What is the output of this program?
#include <iostream> using namespace std; int main(){ int i;char *arr[] = {"C", "C++", "Java", "VBA"}; char *(*ptr)[4] = &arr;cout << ++(*ptr)[2]; return 0; } Ava Java C++ Compile time error

39 37. Function called from within a try block____ throw exception?
Always Maybe Never None of these

40 38. Which operator is used in catch-all handler?
Ellipses operator Ternary operator String operator Unary operator

41 39. What function will be called when we have a uncaught exception?
Terminate Throw Catch None of these

42 40. How can we be ensured that function throw specified exception?
Defining multiple try and catch block inside a function Defining generic function within try block Defining function with throw clause It is not possible in CPP to restrict a function

43 41. What will not be called when terminate is arise in constructor:
Main Destructor Class None of these

44 42. In nested try block, if inner catch handler gets executed, then _____________ .
Program execution stops immediately. Outer catch handler will also get executed. Compiler will jump to the outer catch handler and then executes remaining executable statements of main (). Compiler will execute remaining executable statements of outer try block and then the main ().

45 43. We can replace throw () with?
For Return Break Exit

46 44. Throwing an unhandled exception causes standard library function then _______ to be invoked.
Stop () Abborted () terminate() Abandon()

47 45. Choose the most suitable option for returning the logical error in program.
Use constructor and destructor Set a global error indicator Use break keyword none of the mentioned

48 Improve the exception safety
46. RAII is used for? Improve the exception safety Terminate the program Exit from the block None of mentioned

49 47. How many levels are there in exception safety?
1 2 3 4

50 48. Error handling alternative can:
Terminate the program Use the stack Exit from the block None of these

51 49. What will happen when an exception is not processed?
It will eat up lot of memory and program size Terminate the program Crash the compiler None of the mentioned

52 50. Inheritance is a way to: (Choose all that apply) 1) Make general class into more specific classes 2) Pass arguments to the object of the class 3) Add features in existing class without rewriting it 4) Improve data hiding and encapsulation 2;3 1;3 1;4 2;4

53 The Results


Download ppt "C ++ MULTIPLE CHOICE QUESTION"

Similar presentations


Ads by Google