MCQOPTIONS
Saved Bookmarks
This section includes 144 Mcqs, each offering curated multiple-choice questions to sharpen your Computer Science Mcqs knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
If base class has constructor with arguments, then it is ________________ for the derived class to have constructor and pass the arguments to base class constructor. |
| A. | Optional |
| B. | Mandatory |
| C. | Compiler dependent |
| D. | Error |
| Answer» C. Compiler dependent | |
| 2. |
During a class inheritance in CPP, if the visibility mode or mode of derivation is not provided, then by default visibility mode is ___________. |
| A. | public |
| B. | protected |
| C. | private |
| D. | Friend |
| Answer» D. Friend | |
| 3. |
Logical expressions produce ____________ type results. |
| A. | explicit |
| B. | garbage |
| C. | bool |
| D. | static |
| Answer» D. static | |
| 4. |
Private members of the class are accessible only to the members of the same class. |
| A. | True |
| B. | False |
| Answer» C. | |
| 5. |
Due to ios::trunc mode, the file is truncated to zero length. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 6. |
While redefining a virtual function in the derived class, if its prototype is changed then ___________________ . |
| A. | It will be overloaded by the compiler |
| B. | Its virtual nature will be lost |
| C. | both a and b |
| D. | Compiler will generate “Prototype mismatch error” |
| Answer» D. Compiler will generate “Prototype mismatch error” | |
| 7. |
Can struct be used as Base class for inheritance ? |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 8. |
If a program uses Inline Function, then the function is expanded inline at ___________. |
| A. | Compile time |
| B. | Run time |
| C. | Both a and b |
| D. | None of these |
| Answer» C. Both a and b | |
| 9. |
Can we alter/modify the values of data members of a class inside const member function? |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 10. |
Which of the following is not used to seek a file pointer? |
| A. | ios::cur |
| B. | ios::set |
| C. | ios::end |
| D. | ios::beg |
| Answer» C. ios::end | |
| 11. |
During dynamic memory allocation in CPP, new operator returns _________ value if memory allocation is unsuccessful. |
| A. | False |
| B. | Zero |
| C. | None of these |
| Answer» C. None of these | |
| 12. |
Which of the followings is/are pointer-to-member declarator? |
| A. | ->* |
| B. | .* |
| C. | ::* |
| D. | both a and b |
| Answer» D. both a and b | |
| 13. |
Default value of static variable is_____ . |
| A. | 0 |
| B. | 1 |
| C. | Garbage value |
| D. | Compiler dependent |
| Answer» B. 1 | |
| 14. |
________ are used to format the data display in CPP. |
| A. | Iterators |
| B. | Punctuators |
| C. | Manipulators |
| D. | Allocators |
| Answer» D. Allocators | |
| 15. |
Reusability of the code can be achieved in CPP through ______ . |
| A. | Polymorphism |
| B. | Encapsulation |
| C. | Inheritance |
| D. | Both a and c |
| Answer» D. Both a and c | |
| 16. |
Can we pass parameters to base class constructor though derived class or derived class constructor? |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 17. |
A try block can be nested under another try block. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 18. |
We can prevent a function from throwing any exceptions. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 19. |
In nested try blocks, there is no need to specify catch handler for inner try block. Outer catch handler is sufficient for the program. |
| A. | True |
| B. | False |
| Answer» C. | |
| 20. |
Functions called from within a try block may also throw exception. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 21. |
The explicit keyword is an optional decoration for the constructors that takes exactly_____argument. |
| A. | No argument |
| B. | Two |
| C. | Three |
| D. | One |
| Answer» E. | |
| 22. |
A class can contain objects of other classes and this phenomenon is called_________ . |
| A. | Relationship |
| B. | Object Association |
| C. | Containership |
| D. | None of these |
| Answer» D. None of these | |
| 23. |
If a class contains pure virtual function, then it is termed as____________________ . |
| A. | Virtual class |
| B. | Sealed class |
| C. | Pure Local class |
| D. | Abstract Class |
| Answer» E. | |
| 24. |
In a program, If there exists a function template with two parameters and normal function say void add(int , int), so add(3,4) will _____________________ . |
| A. | Invoke function template body as it is generic one |
| B. | Invokes normal function as it exactly matches with its prototype |
| C. | Not be called and Compiler issues warning |
| D. | Not be called and Compiler issues ambiguity in calling add() |
| Answer» C. Not be called and Compiler issues warning | |
| 25. |
Attempting to throw an exception that is not supported by a function call results in calling _____________ library function. |
| A. | indeterminate() |
| B. | unutilized() |
| C. | unexpected() |
| D. | unpredicted() |
| Answer» D. unpredicted() | |
| 26. |
In CPP, dynamic memory allocation is done using ______________ operator. |
| A. | calloc() |
| B. | malloc() |
| C. | allocate |
| D. | New |
| Answer» E. | |
| 27. |
Which of the following is not a file opening mode ____ . |
| A. | ios::ate |
| B. | ios::nocreate |
| C. | ios::noreplace |
| D. | ios::truncate |
| Answer» E. | |
| 28. |
Is it possible to define a constructor with default arguments? |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 29. |
How can we restrict a function to throw certain exceptions? |
| A. | Defining multiple try and catch block inside a function |
| B. | Defining generic function within try block |
| C. | Defining function with throw clause |
| D. | It is not possible in CPP to restrict a function |
| Answer» D. It is not possible in CPP to restrict a function | |
| 30. |
In any ways, Non-member function cannot have access to the private data of the class. |
| A. | True |
| B. | False |
| Answer» C. | |
| 31. |
When a virtual function is redefined by the derived class, it is called___________. |
| A. | Overloading |
| B. | Overriding |
| C. | Rewriting |
| D. | All of these |
| Answer» C. Rewriting | |
| 32. |
Private members of the class are not inheritable. |
| A. | True |
| B. | False |
| Answer» C. | |
| 33. |
Can we allocate memory for the objects dynamically in CPP? |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 34. |
Which of the following is not a casting operator in CPP? |
| A. | explicit_cast |
| B. | static_cast |
| C. | dynamic_cast |
| D. | reinterpret_cast |
| Answer» B. static_cast | |
| 35. |
If the derived class is struct, then default visibility mode is _______ . |
| A. | public |
| B. | protected |
| C. | private |
| D. | struct can’t inherit class |
| Answer» B. protected | |
| 36. |
___________ header file is used for manipulators. |
| A. | < iomanipulator.h> |
| B. | < stdiomanip.h> |
| C. | < stdmanip.h> |
| D. | < iomanip.h> |
| Answer» E. | |
| 37. |
Which of the following manipulator is used for the representing octal equivalent of a given decimal number? |
| A. | oct |
| B. | setbase(8) |
| C. | tobase(8) |
| D. | both a and b |
| E. | all a, b, c |
| Answer» E. all a, b, c | |
| 38. |
const member function does not allow to modify/alter value of any data member of the class. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 39. |
Scope resolution operator is used______ . |
| A. | to resolve the scope of global variables only |
| B. | to resolve the scope of functions of the classes only |
| C. | to resolve scope of global variables as well as functions of the classes |
| D. | None of these |
| Answer» D. None of these | |
| 40. |
The purpose of explicit keyword is to tell the compiler that a certain constructor may not be used to implicitly cast an expression to its class type. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 41. |
If inner catch handler is not able to handle the exception then__________ . |
| A. | Compiler will look for outer try handler |
| B. | Program terminates abnormally |
| C. | Compiler will check for appropriate catch handler of outer try block |
| D. | None of these |
| Answer» D. None of these | |
| 42. |
Which one is suitable syntax for function template? |
| A. | template< class T> return_type Function_Name(parameters) |
| B. | template< typename T> return_type Function_Name(parameters) |
| C. | both a and b |
| D. | None of these |
| Answer» D. None of these | |
| 43. |
It is not possible to combine two or more file opening mode in open () method. |
| A. | True |
| B. | False |
| Answer» C. | |
| 44. |
In case of operator overloading, operator function must be ______ . 1. Static member functions 2. Non- static member functions 3. Friend Functions |
| A. | Only 2 |
| B. | Only 1, 3 |
| C. | Only 2 , 3 |
| D. | All 1 , 2, 3 |
| Answer» D. All 1 , 2, 3 | |
| 45. |
Generic catch handler is represented by ______________ . |
| A. | catch(..,) |
| B. | catch(---) |
| C. | catch(…) |
| D. | catch( void x) |
| Answer» D. catch( void x) | |
| 46. |
While overloading binary operators using member function, it requires ___ argument/s. |
| A. | Zero |
| B. | One |
| C. | Two |
| D. | Three |
| Answer» C. Two | |
| 47. |
If abstract class is inherited by derived class, then_______________ . |
| A. | Derived class should provide definition for all the pure virtual functions |
| B. | Derived class also become abstract if fails to implement pure virtual functions |
| C. | Objects of derived class can’t be created if it fails to implement pure virtual functions |
| D. | All of these |
| Answer» E. | |
| 48. |
Streams that will be performing both input and output operations must be declared as class _________ . |
| A. | iostream |
| B. | fstream |
| C. | stdstream |
| D. | Stdiostream |
| Answer» C. stdstream | |
| 49. |
Exception handlers are declared with ____________ keyword. |
| A. | Try |
| B. | catch |
| C. | throw |
| D. | Finally |
| Answer» C. throw | |
| 50. |
Which of the following statements are true about Catch handler? 1. It must be placed immediately after try block T. 2. It can have multiple parameters. 3. There must be only one catch handler for every try block. 4. There can be multiple catch handler for a try block T. 5. Generic catch handler can be placed anywhere after try block. |
| A. | Only 1, 4, 5 |
| B. | Only 1, 2, 3 |
| C. | Only 1, 4 |
| D. | Only 1, 2 |
| Answer» D. Only 1, 2 | |