C ++ MULTIPLE CHOICE QUESTION
Check your Knowledge Press to Start www.prolearninghub.com
1. The default executable generation on UNIX for a C++ program is ___ a.exe a a.out out.a www.prolearninghub.com
2. ____ is also called as abstract class. Virtual class Pure virtual class Derive class None of these www.prolearninghub.com
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 www.prolearninghub.com
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 www.prolearninghub.com
5. Abstract class is used: A) Base class only B) Derived class Both A and B None of the mentioned www.prolearninghub.com
6. Which of the following correctly declare an array? Int array[10]; Array array []; Arr array[]; None of these www.prolearninghub.com
7. An array is: Series of element of same type Series of element Series of element of different type None of these www.prolearninghub.com
8. To access the 100th element in a array. What should we write? www.prolearninghub.com
9. To access the first element of the array we should write: www.prolearninghub.com
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 www.prolearninghub.com
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 www.prolearninghub.com
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 www.prolearninghub.com
13. A 32 bit generic pointer has: 2 bits 4 bits 6 bits 8 bits www.prolearninghub.com
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; 15 18 21 21 21 21 24 24 24 Compile time error www.prolearninghub.com
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 www.prolearninghub.com
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 www.prolearninghub.com
17. What is template? A template is used to manipulate the class A template is used for creating the attributes None of the mentioned www.prolearninghub.com
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 www.prolearninghub.com
19. Which one is correct declaration of template? None of the mentioned www.prolearninghub.com
20. What keyword we used to handle an exception? Try Throw Catch None of the mentioned www.prolearninghub.com
21. Which keyword we use to catch an exception? Throw Catch try None of these www.prolearninghub.com
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 www.prolearninghub.com
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. www.prolearninghub.com
24. Return type of uncaught_exception() is ________________ . int bool char * double www.prolearninghub.com
25. Can we write throw clause inside catch handler? Yes No www.prolearninghub.com
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. www.prolearninghub.com
27. Catch handler can have multiple parameters. False True www.prolearninghub.com
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 www.prolearninghub.com
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 www.prolearninghub.com
30. Which exception is thrown by dynamic_cast? Bad_cast bad_typeid bad_exception bad_alloc www.prolearninghub.com
31. An exception can be of only built-In type. True False www.prolearninghub.com
32. Irrespective of exception occurrence, catch handler will always get executed. True False www.prolearninghub.com
33. What will happen when an exception is uncaught? Error arise Program will run Execute continuously None of the mentioned www.prolearninghub.com
34. _____ can catch all type of exceptions? Catch-all handler Catch handler Catch none handler None of these www.prolearninghub.com
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 www.prolearninghub.com
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 www.prolearninghub.com
37. Function called from within a try block____ throw exception? Always Maybe Never None of these www.prolearninghub.com
38. Which operator is used in catch-all handler? Ellipses operator Ternary operator String operator Unary operator www.prolearninghub.com
39. What function will be called when we have a uncaught exception? Terminate Throw Catch None of these www.prolearninghub.com
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 www.prolearninghub.com
41. What will not be called when terminate is arise in constructor: Main Destructor Class None of these www.prolearninghub.com
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 (). www.prolearninghub.com
43. We can replace throw () with? For Return Break Exit www.prolearninghub.com
44. Throwing an unhandled exception causes standard library function then _______ to be invoked. Stop () Abborted () terminate() Abandon() www.prolearninghub.com
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 www.prolearninghub.com
Improve the exception safety 46. RAII is used for? Improve the exception safety Terminate the program Exit from the block None of mentioned www.prolearninghub.com
47. How many levels are there in exception safety? 1 2 3 4 www.prolearninghub.com
48. Error handling alternative can: Terminate the program Use the stack Exit from the block None of these www.prolearninghub.com
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 www.prolearninghub.com
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 www.prolearninghub.com
The Results